GNU parallel

Parallel
Developer(s) GNU Project
Stable release
20160822[1] / August 22, 2016 (2016-08-22)
Repository git.savannah.gnu.org/cgit/parallel.git
Written in Perl
Operating system GNU
Type Utility
License GPLv3
Website www.gnu.org/software/parallel/

GNU parallel is a command-line driven utility for Linux and other Unix-like operating systems which allows the user to execute shell scripts in parallel. GNU parallel is free software, written by Ole Tange in Perl. It is available under the terms of GPLv3.[2]

Usage

Introduction video, Part 1
Introduction video, Part 2

The most common usage is to replace the shell loop, for example

    for x in `cat list` ; do 
        do_something "$x"
    done | process_output

to the form of

    cat list | parallel do_something | process_output

where the file list contains arguments for do_something and where process_output may be empty.

Scripts using parallel are often easier to read than scripts using pexec.

The program parallel features also

By default, parallel runs as many jobs in parallel as there are CPU cores.

Examples

 find . -name "*.foo" | parallel grep bar

The above is the parallel equivalent to:

 find . -name "*.foo" -exec grep bar {} +

This searches in all files in the current directory and its subdirectories whose name end in .foo for occurrences of the string bar. The parallel command will work as expected unless a file name contains a newline. In order to avoid this limitation one may use:

 find . -name "*.foo" -print0 | parallel -0 grep bar

The above command uses the null character to delimit file names.

 find . -name "*.foo" | parallel -X mv {} /tmp/trash

The above command uses {} to tell parallel to replace {} with the argument list.

 find . -maxdepth 1 -type f -name "*.ogg" | parallel -X -r cp -v -p {} /home/media

The command above does the same as:

 cp -v -p *.ogg /home/media

however, the former command which uses find/parallel/cp is more resource efficient and will not halt with an error if the expansion of *.ogg is too large for the shell.

Wikimedia Commons has media related to GNU parallel.

See also

References

  1. Insivest, Ole (22 August 2016). "GNU Parallel 20160822 ('Og Nomekop') released". parallel (Mailing list).
  2. "GNU Parallel". GNU.org.
This article is issued from Wikipedia - version of the 8/25/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.