Hacker News new | ask | show | jobs
by anthonyhn 1166 days ago
GNU Parallel is pretty useful. You can use it to run command line programs in parallel. For example, if you wanted to gzip compress all individual files in a directory and limit the number of jobs equal to the number of CPU cores on your machine:

ls | parallel --dry-run --jobs `nproc` 'gzip {}'

(Note you have to remove the --dry-run switch to actually run this, --dry-run only prints out the commands parallel will run, not actually execute them)

1 comments

Sometimes xargs -P is useful too, but it's much more limited than GNU parallel.
I think `xargs -P -I` is probably the closest thing to magic when it comes to commands.