SHTK_LIST_FILTER(3)

πŸ“¦ version 1.7, in nixos 26.05, nixpkgs unstable

πŸ’… shtk_list_filter(3) β€” the manual page, but make it cute

ok so real talk: this is the shtk_list_filter manual page, and if you're here it's because you want to keep some of a list and yeet the rest 🫢 and honestly? iconic behavior. Let's get into it bestie ✨


🌸 NAME 🌸

shtk_list_filter β€” filters the elements of a list based on a pattern πŸŽ€

like a bouncer for your list. only the ones that match the vibe check get in πŸ’…


πŸ“š LIBRARY πŸ“š

You gotta shtk_import list first, bestie. no import, no function, no slay. periodt πŸ’–


✨ SYNOPSIS ✨

shtk_list_filter pattern [list_value1 .. list_valueN]

so it's pattern first (that's your rule), then all your list values lined up after it like 🧚 the pattern is the main character, lowkey.


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so shtk_list_filter selects and returns the elements of the list you hand it β€” those are the args list_value1 through list_valueN β€” but only the ones that match the given shell pattern. the rest? not invited. sorry not sorry πŸ’€

and the important bit, ngl, don't skip this: each list value must be provided as a separate positional parameter. separate. positional. parameter. every single one πŸ”₯ no stuffing them all into one string, no funny business, iykyk.

πŸŽ€ quick vibe check: shell patterns are doing the matching here. your pattern is the whole rulebook.

🌈 EXAMPLES 🌈

here's the moment you've been waiting for, no cap πŸ“

original="foo foobar baz frobz"
filtered="$(shtk_list_filter 'foo*' ${original})"
echo "Results: ${filtered}"

look at that. foo and foobar made the cut, baz and frobz are crying in the group chat 😭 note how ${original} is unquoted so each word becomes its own positional parameter β€” that's exactly the "separate positional parameter" thing we were yelling about. chef's kiss πŸ’œ


πŸ‘€ SEE ALSO πŸ‘€

  • shtk(3) β€” the whole family πŸ’–
  • shtk_list(3) β€” the list functions, your new besties 🫢

πŸ•°οΈ HISTORY πŸ•°οΈ

shtk_list_filter first appeared in shtk 1.0 β€” a legend from day one πŸ‘‘βœ¨


that's the whole page bestie, go filter something and absolutely ate πŸ’…πŸ”₯ β€” xoxo, the Debian crew, November 7, 2014 πŸ¦‹ (source/version + date, folded in all cute like, as promised πŸŽ€)

πŸ“¦ where this page comes from