Parallel (xargs alt)

GNU Parallel was designed by keeping xargs in mind, so majority of the command line options and parameters might match with xargs command. - How To Run Multiple Commands In Parallel on Linux

  • Sem - semaphore for executing shell command lines in parallel

Passing arguments

By Default parallel convert STDOUT args to ARGV

$ ls -1 | parallel echo

Using --pipe Instead of treating the data on stdin (standard input) as arguments for a command to run, the data will be sent to stdin (standard input) of the command. - Spreading block of data

$ command_A | parallel --pipe command_B | command_C

Parallel vs X

  • parallel vs xargs
    • xargs deals badly with special characters (such as space, ‘ and “).
    • xargs can run a given number of jobs in parallel, but has no support for running number-of-cpu-cores jobs in parallel.
    • xargs has no support for grouping the output, therefore output may run together, e.g. the first half of a line is from one process and the last half of the line is from another process.
    • xargs has no support for keeping the order of the output, therefore if running jobs in parallel using xargs the output of the second job cannot be postponed till the first job is done.
    • xargs has no support for running jobs on remote computers.
    • xargs has no support for context replace, so you will have to create the arguments.

Install

replace 20160922 with the version you want:

wget http://ftpmirror.gnu.org/parallel/parallel-20160922.tar.bz2
bzip2 -dc parallel-*.tar.bz2 | tar xvf -
cd parallel-*
./configure && make && sudo make install
Written on August 7, 2021, Last update on August 22, 2021
parallel cli