Accelerated command processing with GNU Parallel

Lead Image © Ilka Burckhardt, Fotolia.com

Lead Image © Ilka Burckhardt, Fotolia.com

Multiple Personalities

With the snazzy little program GNU Parallel, you can make use of the full power of your multicore CPUs through scripts.

When you get back from vacation, you probably have tons of snapshots stored on your camera. If you want to reduce the resolution of photos so you can upload your pics to a web gallery, the following one-liner for Mogrify from the ImageMagick package is usually sufficient:

$ for i in *.tif; do mogrify -resize 50% $i; done

The command combs through all files with the .tif ending in the current directory (for i in *.tif ) and has Mogrify reduce their size by a half (mogrify -resize 50% ). Because the command processes the files sequentially, a modern core processor running at full speed is still basically twiddling its thumbs. It would be much more effective and faster to process multiple photos simultaneously. This is where the somewhat unjustly overlooked tool called GNU Parallel comes in.

[...]

Use Express-Checkout link below to read the full article (PDF).