GNU parallel

From Wikipedia, the free encyclopedia
(Redirected from Parallel (software))

Template:Short description

Page Module:Message box/ambox.css has no content.

Page Module:Infobox/styles.css has no content.

Parallel
[[Programmer|DeveloperTemplate:Pluralize from text]]GNU Project
Template:Infobox software/simple
Written inPerl
EnginePage Template:Plainlist/styles.css has no content.Template:EditAtWikidata
Operating systemGNU
TypeUtility
LicenseGPLv3
WebsiteScript error: No such module "WikidataIB".
RepositoryPage Template:Plainlist/styles.css has no content.

Script error: No such module "Check for conflicting parameters".

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

Usage

File:GNU Parallel script processing and execution - intro video Part 1.ogv File:GNU Parallel script processing and execution - intro video Part 2.ogv

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

while read x; do 
    do_something "$x"
done < list

to the form of

parallel do_something < list

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

  • grouping of standard output and standard error so the output of the parallel running jobs do not run together;
  • retaining the order of output to remain the same order as input;
  • dealing nicely with filenames containing special characters such as space, single quote, double quote, ampersand, and UTF-8 encoded characters;

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 expands {} with as many arguments as the command line length permits, distributing them evenly among parallel jobs if required. This can lower process overhead for short-lived commands that take less time to finish than they do to launch.

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.

Page Module:Side box/styles.css has no content.Page Template:Sister project/styles.css has no content.

See also

References

Page Template:Reflist/styles.css has no content.

  1. ^ Page Module:Citation/CS1/styles.css has no content.Tange, Ole (21 Oct 2024). "GNU Parallel 20241022 ('Sinwar Nasrallah') released [stable]". parallel (Mailing list).
  2. ^ Page Module:Citation/CS1/styles.css has no content."GNU Parallel". GNU.org.

Lua error in package.lua at line 80: module 'Module:Navbox/configuration' not found.