Friday, September 8, 2017

Choosing the first available program from list of options

GNU tar accepts an external program to perform compression, via the option --use-compress-program. I'd normally want pigz if it's available, but if not, fallback to gzip. Is there a compact way to get represent this? Yes! which --skip-alias --skip-functions pigz gzip 2>/dev/null | head -1 GNU...