Categories Photography Résumé About Me

Output --version for all executables of a given name

13 Apr 2014

The output of which -a ruby ends up being a path per line for every 'ruby' executable found within the user's PATH. This is an excellent type of output to pipe into another command—or series of them.

which -a ruby | while read line; do echo $line; echo `$line --version`; done

If that code were expanded out it would look like:

while read line;
    echo $line;
    echo `$line --version`;

Sadly this is basically my first attempt to use piping in any meaningful way.

Filed under

comments powered by Disqus