in reply to Finding commands in Unix PATH
Zsh keeps a hash of all commands in PATH (updated when you run hash -r and/or twiddle PATH) in a parameter.
$ for i in ${(onk)commands}; [[ "$i" == *grep* ]] && print $i bzegrep bzfgrep bzgrep egrep fgrep git-grep grep grep-changelog msggrep pcregrep podgrep tcgrep xml_grep zegrep zfgrep zgrep zipgrep
Granted that's a zsh pattern not a regexp (however if you really want to you can compile in pcre support when you build zsh :). Functionalization left as an exercise for the reader.
Update: Ooop, note that that's run with setopt short_loops; without that you'd need the usual shell-y do ... done around the body.
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding commands in Unix PATH
by jdporter (Paladin) on Jun 05, 2008 at 13:50 UTC | |
by Fletch (Bishop) on Jun 05, 2008 at 14:00 UTC |