in reply to Re: Finding commands in Unix PATH
in thread Finding commands in Unix PATH

perl -le "/grep/ and print for @ARGV" ${(onk)commands}
whatever ${(onk)commands} is/does. I'm not familiar with the peculiarities zsh.

Replies are listed 'Best First'.
Re^3: Finding commands in Unix PATH
by Fletch (Bishop) on Jun 05, 2008 at 14:00 UTC

    Zsh has several flags that affect parameter expansion. The k flag says to expand a hash into a list of its keys (rather than the default which is to expand into a list of its values; or you index it like ${commands[ls]} and get the path to ls). The o flag says to sort the resulting expansion by name in ascending order (the on is actually wrong but works; I was confuzzling glob expansion qualifiers where it's oX where X specifies what to sort on (e.g. n for filename, or m for modification time)).

    So Perl's in a run for its money with regards to line-noisy-ness compared to terse zsh. :)

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.