Posted February 22, 2015
![avatar](http://images.gog.com/e042d6b70bbe50b6e96c3a20ddbd5bcc5299ae09e14b1f2ad1a305ada1fe5e08_avm.jpg)
![avatar](http://images.gog.com/e042d6b70bbe50b6e96c3a20ddbd5bcc5299ae09e14b1f2ad1a305ada1fe5e08_avm.jpg)
find . -iname "*.png" -print0 | parallel -0X advdef -z4 {}
Here's how it works:
1. GNU parallel takes a list of files or commands and performs some action on them in parallel. (In this case, feeding them to "advdef -z4")
2. -print0 causes find to output a list of files separated by binary NUL characters (one of only two characters not allowed in filenames on POSIX-compliant filesystems, the other being the / path separator.)
3. The -0 flag tells GNU parallel to expect a NUL-separated list rather than a newline-separated list.
4. The -X flag to GNU parallel is equivalent to --exec + with find. It tells it to feed multiple files to the same command up to the command-line length limit.
5. If you don't specify a -j option to GNU parallel, it checks how many CPU cores you have and runs one subprocess for each.
If it's going to take a long time, you may also want to consider using -0 --eta instead of -0X so GNU parallel will display a progress readout and estimated time to completion.
The GNU parallel manual page has examples as well as comparisons to other similar tools, if you find that you don't have access to GNU parallel for some reason.
![avatar](http://images.gog.com/2cb98f22a170352a32e8c7d57fb4becfd0723eb419c2e856ad8ee0910c2a8499_avm.jpg)
![avatar](http://images.gog.com/e042d6b70bbe50b6e96c3a20ddbd5bcc5299ae09e14b1f2ad1a305ada1fe5e08_avm.jpg)
Yes, it does rule out closed-source code, but that's a perfectly decent trade-off to make and really cuts the crap, given that people who produce crap would never be willing to open-source their precious "first on earth" solution for the community to "plunder", "steal", or "ruin". (And the various Linux distros' package repositories wouldn't take it if you paid them.)
Post edited February 22, 2015 by ssokolow