| filterexec - Echo those arguments with which the given command returns zero. |
filterexec - Echo those arguments with which the given command returns zero.
filterexec COMMAND [ARGS] -- DATA-1 [DATA-2 [... DATA-n]]
Prints each DATA (1 per line) only if command COMMAND ARGS DATA exits succesfully, ie. with zero exit status.
If you want to evaluate not command line arguments, but data read on STDIN,
then combine filterexec(1) with foreach(1).
filterexec test -d -- $(ls)
Shows only the directories.
The shell's tokenization may wrongly splits up file names containing space.
Perhaps set IFS to newline only.
ls -1 | foreach filterexec test -d --
Same, but file names are supplied 1-by-1, not all at once,
hence filterexec(1) is invoked multiple times.