\input texinfo
@setfilename parallel.info

@documentencoding utf-8

@settitle parallel - build and execute shell command lines from standard input in parallel

@node Top
@top parallel

@menu
* NAME::
* SYNOPSIS::
* DESCRIPTION::
* OPTIONS::
* EXAMPLE@asis{:} Working as xargs -n1. Argument appending::
* EXAMPLE@asis{:} Reading arguments from command line::
* EXAMPLE@asis{:} Inserting multiple arguments::
* EXAMPLE@asis{:} Context replace::
* EXAMPLE@asis{:} Compute intensive jobs and substitution::
* EXAMPLE@asis{:} Substitution and redirection::
* EXAMPLE@asis{:} Composed commands::
* EXAMPLE@asis{:} Composed command with multiple input sources::
* EXAMPLE@asis{:} Calling Bash functions::
* EXAMPLE@asis{:} Function tester::
* EXAMPLE@asis{:} Log rotate::
* EXAMPLE@asis{:} Removing file extension when processing files::
* EXAMPLE@asis{:} Removing two file extensions when processing files::
* EXAMPLE@asis{:} Download 24 images for each of the past 30 days::
* EXAMPLE@asis{:} Copy files as last modified date (ISO8601) with added random digits::
* EXAMPLE@asis{:} Digtal clock with "blinking" @asis{:}::
* EXAMPLE@asis{:} Aggregating content of files::
* EXAMPLE@asis{:} Breadth first parallel web crawler/mirrorer::
* EXAMPLE@asis{:} Process files from a tar file while unpacking::
* EXAMPLE@asis{:} Rewriting a for-loop and a while-read-loop::
* EXAMPLE@asis{:} Rewriting nested for-loops::
* EXAMPLE@asis{:} Finding the lowest difference between files::
* EXAMPLE@asis{:} for-loops with column names::
* EXAMPLE@asis{:} Count the differences between all files in a dir::
* EXAMPLE@asis{:} Speeding up fast jobs::
* EXAMPLE@asis{:} Using shell variables::
* EXAMPLE@asis{:} Group output lines::
* EXAMPLE@asis{:} Tag output lines::
* EXAMPLE@asis{:} Keep order of output same as order of input::
* EXAMPLE@asis{:} Parallel grep::
* EXAMPLE@asis{:} Grepping n lines for m regular expressions.::
* EXAMPLE@asis{:} Using remote computers::
* EXAMPLE@asis{:} Transferring of files::
* EXAMPLE@asis{:} Distributing work to local and remote computers::
* EXAMPLE@asis{:} Running the same command on remote computers::
* EXAMPLE@asis{:} Using remote computers behind NAT wall::
* EXAMPLE@asis{:} Parallelizing rsync::
* EXAMPLE@asis{:} Use multiple inputs in one command::
* EXAMPLE@asis{:} Use a table as input::
* EXAMPLE@asis{:} Run the same command 10 times::
* EXAMPLE@asis{:} Working as cat | sh. Resource inexpensive jobs and evaluation::
* EXAMPLE@asis{:} Processing a big file using more cores::
* EXAMPLE@asis{:} Running more than 250 jobs workaround::
* EXAMPLE@asis{:} Working as mutex and counting semaphore::
* EXAMPLE@asis{:} Mutex for a script::
* EXAMPLE@asis{:} Start editor with filenames from stdin (standard input)::
* EXAMPLE@asis{:} Running sudo::
* EXAMPLE@asis{:} GNU Parallel as queue system/batch manager::
* EXAMPLE@asis{:} GNU Parallel as dir processor::
* QUOTING::
* LIST RUNNING JOBS::
* COMPLETE RUNNING JOBS BUT DO NOT START NEW JOBS::
* ENVIRONMENT VARIABLES::
* DEFAULT PROFILE (CONFIG FILE)::
* PROFILE FILES::
* EXIT STATUS::
* DIFFERENCES BETWEEN GNU Parallel AND ALTERNATIVES::
* BUGS::
* REPORTING BUGS::
* AUTHOR::
* LICENSE::
* DEPENDENCIES::
* SEE ALSO::
@end menu

@node NAME
@chapter NAME

parallel - build and execute shell command lines from standard input in parallel

@node SYNOPSIS
@chapter SYNOPSIS

@strong{parallel} [options] [@emph{command} [arguments]] < list_of_arguments

@strong{parallel} [options] [@emph{command} [arguments]] ( @strong{:::} arguments | @strong{:::+} arguments |
@strong{::::} argfile(s) | @strong{::::+} argfile(s) ) ...

@strong{parallel} --semaphore [options] @emph{command}

@strong{#!/usr/bin/parallel} --shebang [options] [@emph{command} [arguments]]

@node DESCRIPTION
@chapter DESCRIPTION

GNU @strong{parallel} is a shell tool for executing jobs in parallel using
one or more computers. A job can be a single command or a small
script that has to be run for each of the lines in the input. The
typical input is a list of files, a list of hosts, a list of users, a
list of URLs, or a list of tables. A job can also be a command that
reads from a pipe. GNU @strong{parallel} can then split the input into
blocks and pipe a block into each command in parallel.

If you use xargs and tee today you will find GNU @strong{parallel} very easy to
use as GNU @strong{parallel} is written to have the same options as xargs. If
you write loops in shell, you will find GNU @strong{parallel} may be able to
replace most of the loops and make them run faster by running several
jobs in parallel.

GNU @strong{parallel} makes sure output from the commands is the same output as
you would get had you run the commands sequentially. This makes it
possible to use output from GNU @strong{parallel} as input for other programs.

For each line of input GNU @strong{parallel} will execute @emph{command} with
the line as arguments. If no @emph{command} is given, the line of input is
executed. Several lines will be run in parallel. GNU @strong{parallel} can
often be used as a substitute for @strong{xargs} or @strong{cat | bash}.

@menu
* Reader's guide::
@end menu

@node Reader's guide
@section Reader's guide

Start by watching the intro videos for a quick introduction:
http://www.youtube.com/playlist?list=PL284C9FF2488BC6D1

Then look at the @strong{EXAMPLE}s after the list of @strong{OPTIONS}. That will
give you an idea of what GNU @strong{parallel} is capable of.

Then spend an hour walking through the tutorial (@strong{man
parallel_tutorial}). Your command line will love you for it.

Finally you may want to look at the rest of this manual if you have
special needs not already covered.

If you want to know the design decisions behind GNU @strong{parallel}, try:
@strong{man parallel_design}. This is also a good intro if you intend to
change GNU @strong{parallel}.

@node OPTIONS
@chapter OPTIONS

@table @asis
@item @emph{command}
@anchor{@emph{command}}

Command to execute.  If @emph{command} or the following arguments contain
replacement strings (such as @strong{@{@}}) every instance will be substituted
with the input.

If @emph{command} is given, GNU @strong{parallel} solve the same tasks as
@strong{xargs}. If @emph{command} is not given GNU @strong{parallel} will behave
similar to @strong{cat | sh}.

The @emph{command} must be an executable, a script, a composed command, or
a function.

@strong{Bash functions}: @strong{export -f} the function first or use @strong{env_parallel}.

@strong{Bash aliases}: Use @strong{env_parallel}.

@strong{Ksh functions and aliases}: Use @strong{env_parallel}.

@strong{Zsh functions and aliases}: Use @strong{env_parallel}.

@strong{Fish functions and aliases}: Use @strong{env_parallel}.

@strong{Ksh functions and aliases}: Use @strong{env_parallel}.

@strong{Pdksh functions and aliases}: Use @strong{env_parallel}.

The command cannot contain the character \257 (macron: ¯).

@item @strong{@{@}}
@anchor{@strong{@{@}}}

Input line. This replacement string will be replaced by a full line
read from the input source. The input source is normally stdin
(standard input), but can also be given with @strong{-a}, @strong{:::}, or
@strong{::::}.

The replacement string @strong{@{@}} can be changed with @strong{-I}.

If the command line contains no replacement strings then @strong{@{@}} will be
appended to the command line.

@item @strong{@{.@}}
@anchor{@strong{@{.@}}}

Input line without extension. This replacement string will be replaced
by the input with the extension removed. If the input line contains
@strong{.} after the last @strong{/} the last @strong{.} till the end of the string will
be removed and @strong{@{.@}} will be replaced with the
remaining. E.g. @emph{foo.jpg} becomes @emph{foo}, @emph{subdir/foo.jpg} becomes
@emph{subdir/foo}, @emph{sub.dir/foo.jpg} becomes @emph{sub.dir/foo},
@emph{sub.dir/bar} remains @emph{sub.dir/bar}. If the input line does not
contain @strong{.} it will remain unchanged.

The replacement string @strong{@{.@}} can be changed with @strong{--er}.

To understand replacement strings see @strong{@{@}}.

@item @strong{@{/@}}
@anchor{@strong{@{/@}}}

Basename of input line. This replacement string will be replaced by
the input with the directory part removed.

The replacement string @strong{@{/@}} can be changed with
@strong{--basenamereplace}.

To understand replacement strings see @strong{@{@}}.

@item @strong{@{//@}}
@anchor{@strong{@{//@}}}

Dirname of input line. This replacement string will be replaced by the
dir of the input line. See @strong{dirname}(1).

The replacement string @strong{@{//@}} can be changed with
@strong{--dirnamereplace}.

To understand replacement strings see @strong{@{@}}.

@item @strong{@{/.@}}
@anchor{@strong{@{/.@}}}

Basename of input line without extension. This replacement string will
be replaced by the input with the directory and extension part
removed. It is a combination of @strong{@{/@}} and @strong{@{.@}}.

The replacement string @strong{@{/.@}} can be changed with
@strong{--basenameextensionreplace}.

To understand replacement strings see @strong{@{@}}.

@item @strong{@{#@}}
@anchor{@strong{@{#@}}}

Sequence number of the job to run. This replacement string will be
replaced by the sequence number of the job being run. It contains the
same number as $PARALLEL_SEQ.

The replacement string @strong{@{#@}} can be changed with @strong{--seqreplace}.

To understand replacement strings see @strong{@{@}}.

@item @strong{@{%@}}
@anchor{@strong{@{%@}}}

Job slot number. This replacement string will be replaced by the job's
slot number between 1 and number of jobs to run in parallel. There
will never be 2 jobs running at the same time with the same job slot
number.

The replacement string @strong{@{%@}} can be changed with @strong{--slotreplace}.

To understand replacement strings see @strong{@{@}}.

@item @strong{@{}@emph{n}@strong{@}}
@anchor{@strong{@{}@emph{n}@strong{@}}}

Argument from input source @emph{n} or the @emph{n}'th argument. This
positional replacement string will be replaced by the input from input
source @emph{n} (when used with @strong{-a} or @strong{::::}) or with the @emph{n}'th
argument (when used with @strong{-N}). If @emph{n} is negative it refers to the
@emph{n}'th last argument.

To understand replacement strings see @strong{@{@}}.

@item @strong{@{}@emph{n}.@strong{@}}
@anchor{@strong{@{}@emph{n}.@strong{@}}}

Argument from input source @emph{n} or the @emph{n}'th argument without
extension. It is a combination of @strong{@{}@emph{n}@strong{@}} and @strong{@{.@}}.

This positional replacement string will be replaced by the input from
input source @emph{n} (when used with @strong{-a} or @strong{::::}) or with the
@emph{n}'th argument (when used with @strong{-N}). The input will have the
extension removed.

To understand positional replacement strings see @strong{@{}@emph{n}@strong{@}}.

@item @strong{@{}@emph{n}/@strong{@}}
@anchor{@strong{@{}@emph{n}/@strong{@}}}

Basename of argument from input source @emph{n} or the @emph{n}'th argument.
It is a combination of @strong{@{}@emph{n}@strong{@}} and @strong{@{/@}}.

This positional replacement string will be replaced by the input from
input source @emph{n} (when used with @strong{-a} or @strong{::::}) or with the
@emph{n}'th argument (when used with @strong{-N}). The input will have the
directory (if any) removed.

To understand positional replacement strings see @strong{@{}@emph{n}@strong{@}}.

@item @strong{@{}@emph{n}//@strong{@}}
@anchor{@strong{@{}@emph{n}//@strong{@}}}

Dirname of argument from input source @emph{n} or the @emph{n}'th argument.
It is a combination of @strong{@{}@emph{n}@strong{@}} and @strong{@{//@}}.

This positional replacement string will be replaced by the dir of the
input from input source @emph{n} (when used with @strong{-a} or @strong{::::}) or with
the @emph{n}'th argument (when used with @strong{-N}). See @strong{dirname}(1).

To understand positional replacement strings see @strong{@{}@emph{n}@strong{@}}.

@item @strong{@{}@emph{n}/.@strong{@}}
@anchor{@strong{@{}@emph{n}/.@strong{@}}}

Basename of argument from input source @emph{n} or the @emph{n}'th argument
without extension.  It is a combination of @strong{@{}@emph{n}@strong{@}}, @strong{@{/@}}, and
@strong{@{.@}}.

This positional replacement string will be replaced by the input from
input source @emph{n} (when used with @strong{-a} or @strong{::::}) or with the
@emph{n}'th argument (when used with @strong{-N}). The input will have the
directory (if any) and extension removed.

To understand positional replacement strings see @strong{@{}@emph{n}@strong{@}}.

@item @strong{@{=}@emph{perl expression}@strong{=@}}
@anchor{@strong{@{=}@emph{perl expression}@strong{=@}}}

Replace with calculated @emph{perl expression}. @strong{$_} will contain the
same as @strong{@{@}}. After evaluating @emph{perl expression} @strong{$_} will be used
as the value. It is recommended to only change $_ but you have full
access to all of GNU @strong{parallel}'s internal functions and data
structures. A few convenience functions and data structures have been
made:

@table @asis
@item @strong{Q(}@emph{string}@strong{)}
@anchor{@strong{Q(}@emph{string}@strong{)}}

shell quote a string

@item @strong{pQ(}@emph{string}@strong{)}
@anchor{@strong{pQ(}@emph{string}@strong{)}}

perl quote a string

@item @strong{total_jobs()}
@anchor{@strong{total_jobs()}}

number of jobs in total

@item @strong{$job-}>@strong{slot()}
@anchor{@strong{$job-}>@strong{slot()}}

slot number of job

@item @strong{$job-}>@strong{seq()}
@anchor{@strong{$job-}>@strong{seq()}}

sequence number of job

@item @strong{@@arg}
@anchor{@strong{@@arg}}

the arguments

@end table

Example:

@verbatim
  seq 10 | parallel echo {} + 1 is {= '$_++' =}
  parallel csh -c {= '$_="mkdir ".Q($_)' =} ::: '12" dir'
  seq 50 | parallel echo job {#} of {= '$_=total_jobs()' =}
@end verbatim

See also: @strong{--rpl} @strong{--parens}

@item @strong{@{=}@emph{n} @emph{perl expression}@strong{=@}}
@anchor{@strong{@{=}@emph{n} @emph{perl expression}@strong{=@}}}

Positional equivalent to @strong{@{=perl expression=@}}. To understand
positional replacement strings see @strong{@{}@emph{n}@strong{@}}.

See also: @strong{@{=perl expression=@}} @strong{@{}@emph{n}@strong{@}}.

@item @strong{:::} @emph{arguments}
@anchor{@strong{:::} @emph{arguments}}

Use arguments from the command line as input source instead of stdin
(standard input). Unlike other options for GNU @strong{parallel} @strong{:::} is
placed after the @emph{command} and before the arguments.

The following are equivalent:

@verbatim
  (echo file1; echo file2) | parallel gzip
  parallel gzip ::: file1 file2
  parallel gzip {} ::: file1 file2
  parallel --arg-sep ,, gzip {} ,, file1 file2
  parallel --arg-sep ,, gzip ,, file1 file2
  parallel ::: "gzip file1" "gzip file2"
@end verbatim

To avoid treating @strong{:::} as special use @strong{--arg-sep} to set the
argument separator to something else. See also @strong{--arg-sep}.

If multiple @strong{:::} are given, each group will be treated as an input
source, and all combinations of input sources will be
generated. E.g. ::: 1 2 ::: a b c will result in the combinations
(1,a) (1,b) (1,c) (2,a) (2,b) (2,c). This is useful for replacing
nested for-loops.

@strong{:::} and @strong{::::} can be mixed. So these are equivalent:

@verbatim
  parallel echo {1} {2} {3} ::: 6 7 ::: 4 5 ::: 1 2 3
  parallel echo {1} {2} {3} :::: <(seq 6 7) <(seq 4 5) \
    :::: <(seq 1 3)
  parallel -a <(seq 6 7) echo {1} {2} {3} :::: <(seq 4 5) \
    :::: <(seq 1 3)
  parallel -a <(seq 6 7) -a <(seq 4 5) echo {1} {2} {3} \
    ::: 1 2 3
  seq 6 7 | parallel -a - -a <(seq 4 5) echo {1} {2} {3} \
    ::: 1 2 3
  seq 4 5 | parallel echo {1} {2} {3} :::: <(seq 6 7) - \
    ::: 1 2 3
@end verbatim

@item @strong{:::+} @emph{arguments}
@anchor{@strong{:::+} @emph{arguments}}

Like @strong{:::} but linked like @strong{--link} to the previous input source.

Contrary to @strong{--link}, values do not wrap: The shortest input source
determines the length.

Example:

@verbatim
  parallel echo ::: a b c :::+ 1 2 3 ::: X Y :::+ 11 22
@end verbatim

@item @strong{::::} @emph{argfiles}
@anchor{@strong{::::} @emph{argfiles}}

Another way to write @strong{-a} @emph{argfile1} @strong{-a} @emph{argfile2} ...

@strong{:::} and @strong{::::} can be mixed.

See @strong{-a}, @strong{:::} and @strong{--link}.

@item @strong{::::+} @emph{argfiles}
@anchor{@strong{::::+} @emph{argfiles}}

Like @strong{::::} but linked like @strong{--link} to the previous input source.

Contrary to @strong{--link}, values do not wrap: The shortest input source
determines the length.

@item @strong{--null}
@anchor{@strong{--null}}

@item @strong{-0}
@anchor{@strong{-0}}

Use NUL as delimiter.  Normally input lines will end in \n
(newline). If they end in \0 (NUL), then use this option. It is useful
for processing arguments that may contain \n (newline).

@item @strong{--arg-file} @emph{input-file}
@anchor{@strong{--arg-file} @emph{input-file}}

@item @strong{-a} @emph{input-file}
@anchor{@strong{-a} @emph{input-file}}

Use @emph{input-file} as input source. If you use this option, stdin
(standard input) is given to the first process run.  Otherwise, stdin
(standard input) is redirected from /dev/null.

If multiple @strong{-a} are given, each @emph{input-file} will be treated as an
input source, and all combinations of input sources will be
generated. E.g. The file @strong{foo} contains @strong{1 2}, the file @strong{bar}
contains @strong{a b c}.  @strong{-a foo} @strong{-a bar} will result in the combinations
(1,a) (1,b) (1,c) (2,a) (2,b) (2,c). This is useful for replacing
nested for-loops.

See also @strong{--link} and @strong{@{}@emph{n}@strong{@}}.

@item @strong{--arg-file-sep} @emph{sep-str}
@anchor{@strong{--arg-file-sep} @emph{sep-str}}

Use @emph{sep-str} instead of @strong{::::} as separator string between command
and argument files. Useful if @strong{::::} is used for something else by the
command.

See also: @strong{::::}.

@item @strong{--arg-sep} @emph{sep-str}
@anchor{@strong{--arg-sep} @emph{sep-str}}

Use @emph{sep-str} instead of @strong{:::} as separator string. Useful if @strong{:::}
is used for something else by the command.

Also useful if you command uses @strong{:::} but you still want to read
arguments from stdin (standard input): Simply change @strong{--arg-sep} to a
string that is not in the command line.

See also: @strong{:::}.

@item @strong{--bar}
@anchor{@strong{--bar}}

Show progress as a progress bar. In the bar is shown: % of jobs
completed, estimated seconds left, and number of jobs started.

It is compatible with @strong{zenity}:

@verbatim
  seq 1000 | parallel -j30 --bar '(echo {};sleep 0.1)' \
    2> >(zenity --progress --auto-kill) | wc
@end verbatim

@item @strong{--basefile} @emph{file}
@anchor{@strong{--basefile} @emph{file}}

@item @strong{--bf} @emph{file}
@anchor{@strong{--bf} @emph{file}}

@emph{file} will be transferred to each sshlogin before a jobs is
started. It will be removed if @strong{--cleanup} is active. The file may be
a script to run or some common base data needed for the jobs.
Multiple @strong{--bf} can be specified to transfer more basefiles. The
@emph{file} will be transferred the same way as @strong{--transferfile}.

@item @strong{--basenamereplace} @emph{replace-str}
@anchor{@strong{--basenamereplace} @emph{replace-str}}

@item @strong{--bnr} @emph{replace-str}
@anchor{@strong{--bnr} @emph{replace-str}}

Use the replacement string @emph{replace-str} instead of @strong{@{/@}} for
basename of input line.

@item @strong{--basenameextensionreplace} @emph{replace-str}
@anchor{@strong{--basenameextensionreplace} @emph{replace-str}}

@item @strong{--bner} @emph{replace-str}
@anchor{@strong{--bner} @emph{replace-str}}

Use the replacement string @emph{replace-str} instead of @strong{@{/.@}} for basename of input line without extension.

@item @strong{--bg}
@anchor{@strong{--bg}}

Run command in background thus GNU @strong{parallel} will not wait for
completion of the command before exiting. This is the default if
@strong{--semaphore} is set.

See also: @strong{--fg}, @strong{man sem}.

Implies @strong{--semaphore}.

@item @strong{--bibtex}
@anchor{@strong{--bibtex}}

@item @strong{--citation}
@anchor{@strong{--citation}}

Print the BibTeX entry for GNU @strong{parallel} and silence citation
notice.

If it is impossible for you to run @strong{--bibtex} you can use
@strong{--will-cite}.

If you use @strong{--will-cite} in scripts to be run by others you are
making it harder for others to see the citation notice.  The
development of GNU @strong{parallel} is indirectly financed through
citations, so if your users do not know they should cite then you are
making it harder to finance development. However, if you pay 10000
EUR, you should feel free to use @strong{--will-cite} in scripts.

@item @strong{--block} @emph{size}
@anchor{@strong{--block} @emph{size}}

@item @strong{--block-size} @emph{size}
@anchor{@strong{--block-size} @emph{size}}

Size of block in bytes to read at a time. The @emph{size} can be postfixed
with K, M, G, T, P, k, m, g, t, or p which would multiply the size
with 1024, 1048576, 1073741824, 1099511627776, 1125899906842624, 1000,
1000000, 1000000000, 1000000000000, or 1000000000000000, respectively.

GNU @strong{parallel} tries to meet the block size but can be off by the
length of one record. For performance reasons @emph{size} should be bigger
than a two records. GNU @strong{parallel} will warn you and automatically
increase the size if you choose a @emph{size} that is too small.

If you use @strong{-N}, @strong{--block-size} should be bigger than N+1 records.

@emph{size} defaults to 1M.

See @strong{--pipe} and @strong{--pipepart} for use of this.

@item @strong{--cat}
@anchor{@strong{--cat}}

Create a temporary file with content. Normally @strong{--pipe}/@strong{--pipepart}
will give data to the program on stdin (standard input). With @strong{--cat}
GNU @strong{parallel} will create a temporary file with the name in @strong{@{@}}, so
you can do: @strong{parallel --pipe --cat wc @{@}}.

Implies @strong{--pipe} unless @strong{--pipepart} is used.

See also @strong{--fifo}.

@item @strong{--cleanup}
@anchor{@strong{--cleanup}}

Remove transferred files. @strong{--cleanup} will remove the transferred
files on the remote computer after processing is done.

@verbatim
  find log -name '*gz' | parallel \
    --sshlogin server.example.com --transferfile {} \
    --return {.}.bz2 --cleanup "zcat {} | bzip -9 >{.}.bz2"
@end verbatim

With @strong{--transferfile @{@}} the file transferred to the remote computer
will be removed on the remote computer.  Directories created will not
be removed - even if they are empty.

With @strong{--return} the file transferred from the remote computer will be
removed on the remote computer.  Directories created will not be
removed - even if they are empty.

@strong{--cleanup} is ignored when not used with @strong{--transferfile} or
@strong{--return}.

@item @strong{--colsep} @emph{regexp}
@anchor{@strong{--colsep} @emph{regexp}}

@item @strong{-C} @emph{regexp}
@anchor{@strong{-C} @emph{regexp}}

Column separator. The input will be treated as a table with @emph{regexp}
separating the columns. The n'th column can be access using
@strong{@{}@emph{n}@strong{@}} or @strong{@{}@emph{n}.@strong{@}}. E.g. @strong{@{3@}} is the 3rd column.

@strong{--colsep} implies @strong{--trim rl}.

@emph{regexp} is a Perl Regular Expression:
http://perldoc.perl.org/perlre.html

@item @strong{--compress}
@anchor{@strong{--compress}}

Compress temporary files. If the output is big and very compressible
this will take up less disk space in $TMPDIR and possibly be faster
due to less disk I/O.

GNU @strong{parallel} will try @strong{lz4}, @strong{lzop}, @strong{pbzip2}, @strong{pigz},
@strong{plzip}, @strong{lzip} @strong{gzip}, @strong{pxz}, @strong{lzma}, @strong{xz}, @strong{bzip2}, in that
order, and use the first available.

@item @strong{--compress-program} @emph{prg}
@anchor{@strong{--compress-program} @emph{prg}}

@item @strong{--decompress-program} @emph{prg}
@anchor{@strong{--decompress-program} @emph{prg}}

Use @emph{prg} for (de)compressing temporary files. It is assumed that @emph{prg
-dc} will decompress stdin (standard input) to stdout (standard
output) unless @strong{--decompress-program} is given.

@item @strong{--delimiter} @emph{delim}
@anchor{@strong{--delimiter} @emph{delim}}

@item @strong{-d} @emph{delim}
@anchor{@strong{-d} @emph{delim}}

Input items are terminated by @emph{delim}.  Quotes and backslash are not
special; every character in the input is taken literally.  Disables
the end-of-file string, which is treated like any other argument. The
specified delimiter may be characters, C-style character escapes such
as \n, or octal or hexadecimal escape codes.  Octal and hexadecimal
escape codes are understood as for the printf command.  Multibyte
characters are not supported.

@item @strong{--dirnamereplace} @emph{replace-str}
@anchor{@strong{--dirnamereplace} @emph{replace-str}}

@item @strong{--dnr} @emph{replace-str}
@anchor{@strong{--dnr} @emph{replace-str}}

Use the replacement string @emph{replace-str} instead of @strong{@{//@}} for
dirname of input line.

@item @strong{-E} @emph{eof-str}
@anchor{@strong{-E} @emph{eof-str}}

Set the end of file string to @emph{eof-str}.  If the end of file string
occurs as a line of input, the rest of the input is not read.  If
neither @strong{-E} nor @strong{-e} is used, no end of file string is used.

@item @strong{--delay} @emph{secs}
@anchor{@strong{--delay} @emph{secs}}

Delay starting next job @emph{secs} seconds. GNU @strong{parallel} will pause
@emph{secs} seconds after starting each job. @emph{secs} can be less than 1
second.

@item @strong{--dry-run}
@anchor{@strong{--dry-run}}

Print the job to run on stdout (standard output), but do not run the
job. Use @strong{-v -v} to include the wrapping that GNU Parallel generates
(for remote jobs, @strong{--tmux}, @strong{--nice}, @strong{--pipe}, @strong{--pipepart},
@strong{--fifo} and @strong{--cat}). Do not count on this literaly, though, as the
job may be scheduled on another computer or the local computer if : is
in the list.

@item @strong{--eof}[=@emph{eof-str}]
@anchor{@strong{--eof}[=@emph{eof-str}]}

@item @strong{-e}[@emph{eof-str}]
@anchor{@strong{-e}[@emph{eof-str}]}

This option is a synonym for the @strong{-E} option.  Use @strong{-E} instead,
because it is POSIX compliant for @strong{xargs} while this option is not.
If @emph{eof-str} is omitted, there is no end of file string.  If neither
@strong{-E} nor @strong{-e} is used, no end of file string is used.

@item @strong{--env} @emph{var}
@anchor{@strong{--env} @emph{var}}

Copy environment variable @emph{var}. This will copy @emph{var} to the
environment that the command is run in. This is especially useful for
remote execution.

In Bash @emph{var} can also be a Bash function - just remember to @strong{export
-f} the function, see @strong{command}.

The variable '_' is special. It will copy all exported environment
variables except for the ones mentioned in ~/.parallel/ignored_vars.

To copy the full environment (both exported and not exported
variables, arrays, and functions) use @strong{env_parallel}.

See also: @strong{--record-env}.

@item @strong{--eta}
@anchor{@strong{--eta}}

Show the estimated number of seconds before finishing. This forces GNU
@strong{parallel} to read all jobs before starting to find the number of
jobs. GNU @strong{parallel} normally only reads the next job to run.

The estimate is based on the runtime of finished jobs, so the first
estimate will only be shown when the first job has finished.

Implies @strong{--progress}.

See also: @strong{--bar}, @strong{--progress}.

@item @strong{--fg}
@anchor{@strong{--fg}}

Run command in foreground thus GNU @strong{parallel} will wait for
completion of the command before exiting.

Implies @strong{--semaphore}.

See also @strong{--bg}, @strong{man sem}.

@item @strong{--fifo}
@anchor{@strong{--fifo}}

Create a temporary fifo with content. Normally @strong{--pipe} and
@strong{--pipepart} will give data to the program on stdin (standard
input). With @strong{--fifo} GNU @strong{parallel} will create a temporary fifo
with the name in @strong{@{@}}, so you can do: @strong{parallel --pipe --fifo wc @{@}}.

Beware: If data is not read from the fifo, the job will block forever.

Implies @strong{--pipe} unless @strong{--pipepart} is used.

See also @strong{--cat}.

@item @strong{--filter-hosts}
@anchor{@strong{--filter-hosts}}

Remove down hosts. For each remote host: check that login through ssh
works. If not: do not use this host.

For performance reasons, this check is performed only at the start and
every time @strong{--sshloginfile} is changed. If an host goes down after
the first check, it will go undetected until @strong{--sshloginfile} is
changed; @strong{--retries} can be used to mitigate this.

Currently you can @emph{not} put @strong{--filter-hosts} in a profile,
$PARALLEL, /etc/parallel/config or similar. This is because GNU
@strong{parallel} uses GNU @strong{parallel} to compute this, so you will get an
infinite loop. This will likely be fixed in a later release.

@item @strong{--gnu}
@anchor{@strong{--gnu}}

Behave like GNU @strong{parallel}. This option historically took precedence
over @strong{--tollef}. The @strong{--tollef} option is now retired, and therefore
may not be used. @strong{--gnu} is kept for compatibility.

@item @strong{--group}
@anchor{@strong{--group}}

Group output. Output from each jobs is grouped together and is only
printed when the command is finished. stderr (standard error) first
followed by stdout (standard output). This takes some CPU time. In
rare situations GNU @strong{parallel} takes up lots of CPU time and if it is
acceptable that the outputs from different commands are mixed
together, then disabling grouping with @strong{-u} can speedup GNU
@strong{parallel} by a factor of 10.

@strong{--group} is the default. Can be reversed with @strong{-u}.

See also: @strong{--line-buffer} @strong{--ungroup}

@item @strong{--help}
@anchor{@strong{--help}}

@item @strong{-h}
@anchor{@strong{-h}}

Print a summary of the options to GNU @strong{parallel} and exit.

@item @strong{--halt-on-error} @emph{val}
@anchor{@strong{--halt-on-error} @emph{val}}

@item @strong{--halt} @emph{val}
@anchor{@strong{--halt} @emph{val}}

When should GNU @strong{parallel} terminate? In some situations it makes no
sense to run all jobs. GNU @strong{parallel} should simply give up as soon
as a condition is met.

@emph{val} defaults to @strong{never}, which runs all jobs no matter what.

@emph{val} can also take on the form of @emph{when},@emph{why}.

@emph{when} can be 'now' which means kill all running jobs and halt
immediately, or it can be 'soon' which means wait for all running jobs
to complete, but start no new jobs.

@emph{why} can be 'fail=X', 'fail=Y%', 'success=X', or 'success=Y%' where
X is the number of jobs that has to fail or succeed before halting,
and Y is the percentage of jobs that has to fail or succeed before
halting.

Example:

@table @asis
@item --halt now,fail=1
@anchor{--halt now@comma{}fail=1}

exit when the first job fails. Kill running jobs.

@item --halt soon,fail=3
@anchor{--halt soon@comma{}fail=3}

exit when 3 jobs fail, but wait for running jobs to complete.

@item --halt soon,fail=3%
@anchor{--halt soon@comma{}fail=3%}

exit when 3% of the jobs have failed, but wait for running jobs to complete.

@item --halt now,success=1
@anchor{--halt now@comma{}success=1}

exit when a job succeeds. Kill running jobs.

@item --halt soon,success=3
@anchor{--halt soon@comma{}success=3}

exit when 3 jobs succeeds, but wait for running jobs to complete.

@item --halt now,success=3%
@anchor{--halt now@comma{}success=3%}

exit when 3% of the jobs have succeeded. Kill running jobs.

@end table

For backwards compability these also work:

@table @asis
@item 0
@anchor{0}

never

@item 1
@anchor{1}

soon,fail=1

@item 2
@anchor{2}

now,fail=1

@item -1
@anchor{-1}

soon,success=1

@item -2
@anchor{-2}

now,success=1

@item 1-99%
@anchor{1-99%}

soon,fail=1-99%

@end table

@item @strong{--header} @emph{regexp}
@anchor{@strong{--header} @emph{regexp}}

Use regexp as header. For normal usage the matched header (typically
the first line: @strong{--header '.*\n'}) will be split using @strong{--colsep}
(which will default to '\t') and column names can be used as
replacement variables: @strong{@{column name@}}, @strong{@{column name/@}}, @strong{@{column
name//@}}, @strong{@{column name/.@}}, @strong{@{column name.@}}, @strong{@{=column name perl
expression =@}}, ..

For @strong{--pipe} the matched header will be prepended to each output.

@strong{--header :} is an alias for @strong{--header '.*\n'}.

If @emph{regexp} is a number, it is a fixed number of lines.

@item @strong{--hostgroups}
@anchor{@strong{--hostgroups}}

@item @strong{--hgrp}
@anchor{@strong{--hgrp}}

Enable hostgroups on arguments. If an argument contains '@@' the string
after '@@' will be removed and treated as a list of hostgroups on which
this job is allowed to run. If there is no @strong{--sshlogin} with a
corresponding group, the job will run on any hostgroup.

Example:

@verbatim
  parallel --hostgroups \
    --sshlogin @grp1/myserver1 -S @grp1+grp2/myserver2 \
    --sshlogin @grp3/myserver3 \
    echo ::: my_grp1_arg@grp1 arg_for_grp2@grp2 third_arg@grp1+grp3
@end verbatim

@strong{my_grp1_arg} may be run on either @strong{myserver1} or @strong{myserver2},
@strong{third_arg} may be run on either @strong{myserver1} or @strong{myserver3},
but @strong{arg_for_grp2} will only be run on @strong{myserver2}.

See also: @strong{--sshlogin}.

@item @strong{-I} @emph{replace-str}
@anchor{@strong{-I} @emph{replace-str}}

Use the replacement string @emph{replace-str} instead of @strong{@{@}}.

@item @strong{--replace}[=@emph{replace-str}]
@anchor{@strong{--replace}[=@emph{replace-str}]}

@item @strong{-i}[@emph{replace-str}]
@anchor{@strong{-i}[@emph{replace-str}]}

This option is a synonym for @strong{-I}@emph{replace-str} if @emph{replace-str} is
specified, and for @strong{-I @{@}} otherwise.  This option is deprecated;
use @strong{-I} instead.

@item @strong{--joblog} @emph{logfile}
@anchor{@strong{--joblog} @emph{logfile}}

Logfile for executed jobs. Save a list of the executed jobs to
@emph{logfile} in the following TAB separated format: sequence number,
sshlogin, start time as seconds since epoch, run time in seconds,
bytes in files transferred, bytes in files returned, exit status,
signal, and command run.

For @strong{--pipe} bytes transferred and bytes returned are number of input
and output of bytes.

To convert the times into ISO-8601 strict do:

@verbatim
  perl -a -F"\t" -ne \
    'chomp($F[2]=`date -d \@$F[2] +%FT%T`); print join("\t",@F)'
@end verbatim

See also @strong{--resume} @strong{--resume-failed}.

@item @strong{--jobs} @emph{N}
@anchor{@strong{--jobs} @emph{N}}

@item @strong{-j} @emph{N}
@anchor{@strong{-j} @emph{N}}

@item @strong{--max-procs} @emph{N}
@anchor{@strong{--max-procs} @emph{N}}

@item @strong{-P} @emph{N}
@anchor{@strong{-P} @emph{N}}

Number of jobslots on each machine. Run up to N jobs in parallel.  0
means as many as possible. Default is 100% which will run one job per
CPU core on each machine.

If @strong{--semaphore} is set, the default is 1 thus making a mutex.

@item @strong{--jobs} @emph{+N}
@anchor{@strong{--jobs} @emph{+N}}

@item @strong{-j} @emph{+N}
@anchor{@strong{-j} @emph{+N}}

@item @strong{--max-procs} @emph{+N}
@anchor{@strong{--max-procs} @emph{+N}}

@item @strong{-P} @emph{+N}
@anchor{@strong{-P} @emph{+N}}

Add N to the number of CPU cores.  Run this many jobs in parallel.
See also @strong{--use-cpus-instead-of-cores}.

@item @strong{--jobs} @emph{-N}
@anchor{@strong{--jobs} @emph{-N}}

@item @strong{-j} @emph{-N}
@anchor{@strong{-j} @emph{-N}}

@item @strong{--max-procs} @emph{-N}
@anchor{@strong{--max-procs} @emph{-N}}

@item @strong{-P} @emph{-N}
@anchor{@strong{-P} @emph{-N}}

Subtract N from the number of CPU cores.  Run this many jobs in parallel.
If the evaluated number is less than 1 then 1 will be used.  See also
@strong{--use-cpus-instead-of-cores}.

@item @strong{--jobs} @emph{N}%
@anchor{@strong{--jobs} @emph{N}%}

@item @strong{-j} @emph{N}%
@anchor{@strong{-j} @emph{N}%}

@item @strong{--max-procs} @emph{N}%
@anchor{@strong{--max-procs} @emph{N}%}

@item @strong{-P} @emph{N}%
@anchor{@strong{-P} @emph{N}%}

Multiply N% with the number of CPU cores.  Run this many jobs in
parallel. See also @strong{--use-cpus-instead-of-cores}.

@item @strong{--jobs} @emph{procfile}
@anchor{@strong{--jobs} @emph{procfile}}

@item @strong{-j} @emph{procfile}
@anchor{@strong{-j} @emph{procfile}}

@item @strong{--max-procs} @emph{procfile}
@anchor{@strong{--max-procs} @emph{procfile}}

@item @strong{-P} @emph{procfile}
@anchor{@strong{-P} @emph{procfile}}

Read parameter from file. Use the content of @emph{procfile} as parameter
for @emph{-j}. E.g. @emph{procfile} could contain the string 100% or +2 or
10. If @emph{procfile} is changed when a job completes, @emph{procfile} is
read again and the new number of jobs is computed. If the number is
lower than before, running jobs will be allowed to finish but new jobs
will not be started until the wanted number of jobs has been reached.
This makes it possible to change the number of simultaneous running
jobs while GNU @strong{parallel} is running.

@item @strong{--keep-order}
@anchor{@strong{--keep-order}}

@item @strong{-k}
@anchor{@strong{-k}}

Keep sequence of output same as the order of input. Normally the
output of a job will be printed as soon as the job completes. Try this
to see the difference:

@verbatim
  parallel -j4 sleep {}\; echo {} ::: 2 1 4 3
  parallel -j4 -k sleep {}\; echo {} ::: 2 1 4 3
@end verbatim

If used with @strong{--onall} or @strong{--nonall} the output will grouped by
sshlogin in sorted order.

@item @strong{-L} @emph{max-lines}
@anchor{@strong{-L} @emph{max-lines}}

When used with @strong{--pipe}: Read records of @emph{max-lines}.

When used otherwise: Use at most @emph{max-lines} nonblank input lines per
command line.  Trailing blanks cause an input line to be logically
continued on the next input line.

@strong{-L 0} means read one line, but insert 0 arguments on the command
line.

Implies @strong{-X} unless @strong{-m}, @strong{--xargs}, or @strong{--pipe} is set.

@item @strong{--max-lines}[=@emph{max-lines}]
@anchor{@strong{--max-lines}[=@emph{max-lines}]}

@item @strong{-l}[@emph{max-lines}]
@anchor{@strong{-l}[@emph{max-lines}]}

When used with @strong{--pipe}: Read records of @emph{max-lines}.

When used otherwise: Synonym for the @strong{-L} option.  Unlike @strong{-L}, the
@emph{max-lines} argument is optional.  If @emph{max-lines} is not specified,
it defaults to one.  The @strong{-l} option is deprecated since the POSIX
standard specifies @strong{-L} instead.

@strong{-l 0} is an alias for @strong{-l 1}.

Implies @strong{-X} unless @strong{-m}, @strong{--xargs}, or @strong{--pipe} is set.

@item @strong{--line-buffer}
@anchor{@strong{--line-buffer}}

@item @strong{--lb}
@anchor{@strong{--lb}}

Buffer output on line basis. @strong{--group} will keep the output together
for a whole job. @strong{--ungroup} allows output to mixup with half a line
coming from one job and half a line coming from another
job. @strong{--line-buffer} fits between these two: GNU @strong{parallel} will
print a full line, but will allow for mixing lines of different jobs.

@strong{--line-buffer} takes more CPU power than than both @strong{--group} and
@strong{--ungroup}, but can be faster than @strong{--group} if the CPU is not the
limiting factor.

See also: @strong{--group} @strong{--ungroup}

@item @strong{--xapply}
@anchor{@strong{--xapply}}

@item @strong{--link}
@anchor{@strong{--link}}

Link input sources. Read multiple input sources like @strong{xapply}. If
multiple input sources are given, one argument will be read from each
of the input sources. The arguments can be accessed in the command as
@strong{@{1@}} .. @strong{@{}@emph{n}@strong{@}}, so @strong{@{1@}} will be a line from the first input
source, and @strong{@{6@}} will refer to the line with the same line number
from the 6th input source.

Compare these two:

@verbatim
  parallel echo {1} {2} ::: 1 2 3 ::: a b c
  parallel --link echo {1} {2} ::: 1 2 3 ::: a b c
@end verbatim

Arguments will be recycled if one input source has more arguments than the others:

@verbatim
  parallel --link echo {1} {2} {3} \
    ::: 1 2 ::: I II III ::: a b c d e f g
@end verbatim

See also @strong{--header}, @strong{:::+}, @strong{::::+}.

@item @strong{--load} @emph{max-load}
@anchor{@strong{--load} @emph{max-load}}

Do not start new jobs on a given computer unless the number of running
processes on the computer is less than @emph{max-load}. @emph{max-load} uses
the same syntax as @strong{--jobs}, so @emph{100%} for one per CPU is a valid
setting. Only difference is 0 which is interpreted as 0.01.

@item @strong{--controlmaster}
@anchor{@strong{--controlmaster}}

@item @strong{-M}
@anchor{@strong{-M}}

Use ssh's ControlMaster to make ssh connections faster. Useful if jobs
run remote and are very fast to run. This is disabled for sshlogins
that specify their own ssh command.

@item @strong{--xargs}
@anchor{@strong{--xargs}}

Multiple arguments. Insert as many arguments as the command line
length permits.

If @strong{@{@}} is not used the arguments will be appended to the
line.  If @strong{@{@}} is used multiple times each @strong{@{@}} will be replaced
with all the arguments.

Support for @strong{--xargs} with @strong{--sshlogin} is limited and may fail.

See also @strong{-X} for context replace. If in doubt use @strong{-X} as that will
most likely do what is needed.

@item @strong{-m}
@anchor{@strong{-m}}

Multiple arguments. Insert as many arguments as the command line
length permits. If multiple jobs are being run in parallel: distribute
the arguments evenly among the jobs. Use @strong{-j1} or @strong{--xargs} to avoid this.

If @strong{@{@}} is not used the arguments will be appended to the
line.  If @strong{@{@}} is used multiple times each @strong{@{@}} will be replaced
with all the arguments.

Support for @strong{-m} with @strong{--sshlogin} is limited and may fail.

See also @strong{-X} for context replace. If in doubt use @strong{-X} as that will
most likely do what is needed.

@item @strong{--memfree} @emph{size}
@anchor{@strong{--memfree} @emph{size}}

Minimum memory free when starting another job. The @emph{size} can be
postfixed with K, M, G, T, P, k, m, g, t, or p which would multiply
the size with 1024, 1048576, 1073741824, 1099511627776,
1125899906842624, 1000, 1000000, 1000000000, 1000000000000, or
1000000000000000, respectively.

If the jobs take up very different amount of RAM, GNU @strong{parallel} will
only start as many as there is memory for. If less than @emph{size} bytes
are free, no more jobs will be started. If less than 50% @emph{size} bytes
are free, the youngest job will be killed, and put back on the queue
to be run later.

@item @strong{--minversion} @emph{version}
@anchor{@strong{--minversion} @emph{version}}

Print the version GNU @strong{parallel} and exit.  If the current version of
GNU @strong{parallel} is less than @emph{version} the exit code is
255. Otherwise it is 0.

This is useful for scripts that depend on features only available from
a certain version of GNU @strong{parallel}.

@item @strong{--nonall}
@anchor{@strong{--nonall}}

@strong{--onall} with no arguments. Run the command on all computers given
with @strong{--sshlogin} but take no arguments. GNU @strong{parallel} will log
into @strong{--jobs} number of computers in parallel and run the job on the
computer. @strong{-j} adjusts how many computers to log into in parallel.

This is useful for running the same command (e.g. uptime) on a list of
servers.

@item @strong{--onall}
@anchor{@strong{--onall}}

Run all the jobs on all computers given with @strong{--sshlogin}. GNU
@strong{parallel} will log into @strong{--jobs} number of computers in parallel
and run one job at a time on the computer. The order of the jobs will
not be changed, but some computers may finish before others.

When using @strong{--group} the output will be grouped by each server, so
all the output from one server will be grouped together.

@strong{--joblog} will contain an entry for each job on each server, so
there will be several job sequence 1.

@item @strong{--output-as-files}
@anchor{@strong{--output-as-files}}

@item @strong{--outputasfiles}
@anchor{@strong{--outputasfiles}}

@item @strong{--files}
@anchor{@strong{--files}}

Instead of printing the output to stdout (standard output) the output
of each job is saved in a file and the filename is then printed.

See also: @strong{--results}

@item @strong{--pipe}
@anchor{@strong{--pipe}}

@item @strong{--spreadstdin}
@anchor{@strong{--spreadstdin}}

Spread input to jobs on stdin (standard input). Read a block of data
from stdin (standard input) and give one block of data as input to one
job.

The block size is determined by @strong{--block}. The strings @strong{--recstart}
and @strong{--recend} tell GNU @strong{parallel} how a record starts and/or
ends. The block read will have the final partial record removed before
the block is passed on to the job. The partial record will be
prepended to next block.

If @strong{--recstart} is given this will be used to split at record start.

If @strong{--recend} is given this will be used to split at record end.

If both @strong{--recstart} and @strong{--recend} are given both will have to
match to find a split position.

If neither @strong{--recstart} nor @strong{--recend} are given @strong{--recend}
defaults to '\n'. To have no record separator use @strong{--recend ""}.

@strong{--files} is often used with @strong{--pipe}.

@strong{--pipe} maxes out at around 1 GB/s input, and 100 MB/s output. If
performance is important use @strong{--pipepart}.

See also: @strong{--recstart}, @strong{--recend}, @strong{--fifo}, @strong{--cat},
@strong{--pipepart}, @strong{--files}.

@item @strong{--pipepart}
@anchor{@strong{--pipepart}}

Pipe parts of a physical file. @strong{--pipepart} works similar to
@strong{--pipe}, but is much faster.

If @strong{--block} is left out, @strong{--pipepart} will use a block size that
will result in 10 jobs per jobslot, except if run with
@strong{--round-robin} in which case it will result in 1 job per jobslot.

@strong{--pipepart} has a few limitations:

@table @asis
@item *
@anchor{*}

The file must be a normal file or a block device (technically it must
be seekable) and must be given using @strong{-a} or @strong{::::}. The file cannot
be a pipe or a fifo as they are not seekable.

If using a block device with lot of NUL bytes, remember to set
@strong{--recend ''}.

@item *
@anchor{* 1}

Record counting (@strong{-N}) and line counting (@strong{-L}/@strong{-l}) do not work.

@end table

@item @strong{--plain}
@anchor{@strong{--plain}}

Ignore any @strong{--profile}, $PARALLEL, and ~/.parallel/config to get full
control on the command line (used by GNU @strong{parallel} internally when
called with @strong{--sshlogin}).

@item @strong{--plus}
@anchor{@strong{--plus}}

Activate additional replacement strings: @{+/@} @{+.@} @{+..@} @{+...@} @{..@}
@{...@} @{/..@} @{/...@} @{##@}. The idea being that '@{+foo@}' matches the opposite of
'@{foo@}' and @{@} = @{+/@}/@{/@} = @{.@}.@{+.@} = @{+/@}/@{/.@}.@{+.@} = @{..@}.@{+..@} =
@{+/@}/@{/..@}.@{+..@} = @{...@}.@{+...@} = @{+/@}/@{/...@}.@{+...@}

@strong{@{##@}} is the number of jobs to be run. It is incompatible with
@strong{-X}/@strong{-m}/@strong{--xargs}.

@item @strong{--progress}
@anchor{@strong{--progress}}

Show progress of computations. List the computers involved in the task
with number of CPU cores detected and the max number of jobs to
run. After that show progress for each computer: number of running
jobs, number of completed jobs, and percentage of all jobs done by
this computer. The percentage will only be available after all jobs
have been scheduled as GNU @strong{parallel} only read the next job when
ready to schedule it - this is to avoid wasting time and memory by
reading everything at startup.

By sending GNU @strong{parallel} SIGUSR2 you can toggle turning on/off
@strong{--progress} on a running GNU @strong{parallel} process.

See also @strong{--eta}.

@item @strong{--max-args}=@emph{max-args}
@anchor{@strong{--max-args}=@emph{max-args}}

@item @strong{-n} @emph{max-args}
@anchor{@strong{-n} @emph{max-args}}

Use at most @emph{max-args} arguments per command line.  Fewer than
@emph{max-args} arguments will be used if the size (see the @strong{-s} option)
is exceeded, unless the @strong{-x} option is given, in which case
GNU @strong{parallel} will exit.

@strong{-n 0} means read one argument, but insert 0 arguments on the command
line.

Implies @strong{-X} unless @strong{-m} is set.

@item @strong{--max-replace-args}=@emph{max-args}
@anchor{@strong{--max-replace-args}=@emph{max-args}}

@item @strong{-N} @emph{max-args}
@anchor{@strong{-N} @emph{max-args}}

Use at most @emph{max-args} arguments per command line. Like @strong{-n} but
also makes replacement strings @strong{@{1@}} .. @strong{@{}@emph{max-args}@strong{@}} that
represents argument 1 .. @emph{max-args}. If too few args the @strong{@{}@emph{n}@strong{@}} will
be empty.

@strong{-N 0} means read one argument, but insert 0 arguments on the command
line.

This will set the owner of the homedir to the user:

@verbatim
  tr ':' '\n' < /etc/passwd | parallel -N7 chown {1} {6}
@end verbatim

Implies @strong{-X} unless @strong{-m} or @strong{--pipe} is set.

When used with @strong{--pipe} @strong{-N} is the number of records to read. This
is somewhat slower than @strong{--block}.

@item @strong{--max-line-length-allowed}
@anchor{@strong{--max-line-length-allowed}}

Print the maximal number of characters allowed on the command line and
exit (used by GNU @strong{parallel} itself to determine the line length
on remote computers).

@item @strong{--number-of-cpus}
@anchor{@strong{--number-of-cpus}}

Print the number of physical CPUs and exit (used by GNU @strong{parallel}
itself to determine the number of physical CPUs on remote computers).

@item @strong{--number-of-cores}
@anchor{@strong{--number-of-cores}}

Print the number of CPU cores and exit (used by GNU @strong{parallel} itself
to determine the number of CPU cores on remote computers).

@item @strong{--no-keep-order}
@anchor{@strong{--no-keep-order}}

Overrides an earlier @strong{--keep-order} (e.g. if set in
@strong{~/.parallel/config}).

@item @strong{--nice} @emph{niceness}
@anchor{@strong{--nice} @emph{niceness}}

Run the command at this niceness. For simple commands you can just add
@strong{nice} in front of the command. But if the command consists of more
sub commands (Like: ls|wc) then prepending @strong{nice} will not always
work. @strong{--nice} will make sure all sub commands are niced - even on
remote servers.

@item @strong{--interactive}
@anchor{@strong{--interactive}}

@item @strong{-p}
@anchor{@strong{-p}}

Prompt the user about whether to run each command line and read a line
from the terminal.  Only run the command line if the response starts
with 'y' or 'Y'.  Implies @strong{-t}.

@item @strong{--parens} @emph{parensstring}
@anchor{@strong{--parens} @emph{parensstring}}

Define start and end parenthesis for @strong{@{= perl expression =@}}. The
left and the right parenthesis can be multiple characters and are
assumed to be the same length. The default is @strong{@{==@}} giving @strong{@{=} as
the start parenthesis and @strong{=@}} as the end parenthesis.

Another useful setting is @strong{,,,,} which would make both parenthesis
@strong{,,}:

@verbatim
  parallel --parens ,,,, echo foo is ,,s/I/O/g,, ::: FII
@end verbatim

See also: @strong{--rpl} @strong{@{= perl expression =@}}

@item @strong{--profile} @emph{profilename}
@anchor{@strong{--profile} @emph{profilename}}

@item @strong{-J} @emph{profilename}
@anchor{@strong{-J} @emph{profilename}}

Use profile @emph{profilename} for options. This is useful if you want to
have multiple profiles. You could have one profile for running jobs in
parallel on the local computer and a different profile for running jobs
on remote computers. See the section PROFILE FILES for examples.

@emph{profilename} corresponds to the file ~/.parallel/@emph{profilename}.

You can give multiple profiles by repeating @strong{--profile}. If parts of
the profiles conflict, the later ones will be used.

Default: config

@item @strong{--quote}
@anchor{@strong{--quote}}

@item @strong{-q}
@anchor{@strong{-q}}

Quote @emph{command}.  This will quote the command line so special
characters are not interpreted by the shell. See the section
QUOTING. Most people will never need this.  Quoting is disabled by
default.

@item @strong{--no-run-if-empty}
@anchor{@strong{--no-run-if-empty}}

@item @strong{-r}
@anchor{@strong{-r}}

If the stdin (standard input) only contains whitespace, do not run the command.

If used with @strong{--pipe} this is slow.

@item @strong{--noswap}
@anchor{@strong{--noswap}}

Do not start new jobs on a given computer if there is both swap-in and
swap-out activity.

The swap activity is only sampled every 10 seconds as the sampling
takes 1 second to do.

Swap activity is computed as (swap-in)*(swap-out) which in practice is
a good value: swapping out is not a problem, swapping in is not a
problem, but both swapping in and out usually indicates a problem.

@strong{--memfree} may give better results, so try using that first.

@item @strong{--record-env}
@anchor{@strong{--record-env}}

Record current environment variables in ~/.parallel/ignored_vars. This
is useful before using @strong{--env _}.

See also @strong{--env}.

@item @strong{--recstart} @emph{startstring}
@anchor{@strong{--recstart} @emph{startstring}}

@item @strong{--recend} @emph{endstring}
@anchor{@strong{--recend} @emph{endstring}}

If @strong{--recstart} is given @emph{startstring} will be used to split at record start.

If @strong{--recend} is given @emph{endstring} will be used to split at record end.

If both @strong{--recstart} and @strong{--recend} are given the combined string
@emph{endstring}@emph{startstring} will have to match to find a split
position. This is useful if either @emph{startstring} or @emph{endstring}
match in the middle of a record.

If neither @strong{--recstart} nor @strong{--recend} are given then @strong{--recend}
defaults to '\n'. To have no record separator use @strong{--recend ""}.

@strong{--recstart} and @strong{--recend} are used with @strong{--pipe}.

Use @strong{--regexp} to interpret @strong{--recstart} and @strong{--recend} as regular
expressions. This is slow, however.

@item @strong{--regexp}
@anchor{@strong{--regexp}}

Use @strong{--regexp} to interpret @strong{--recstart} and @strong{--recend} as regular
expressions. This is slow, however.

@item @strong{--remove-rec-sep}
@anchor{@strong{--remove-rec-sep}}

@item @strong{--removerecsep}
@anchor{@strong{--removerecsep}}

@item @strong{--rrs}
@anchor{@strong{--rrs}}

Remove the text matched by @strong{--recstart} and @strong{--recend} before piping
it to the command.

Only used with @strong{--pipe}.

@item @strong{--results} @emph{prefix}
@anchor{@strong{--results} @emph{prefix}}

@item @strong{--res} @emph{prefix}
@anchor{@strong{--res} @emph{prefix}}

Save the output into files. The files will be stored in a directory tree
rooted at @emph{prefix}.  Within this directory tree, each command will result
in two files: @emph{prefix}/<ARGS>/stdout and @emph{prefix}/<ARGS>/stderr, where
<ARGS> is a sequence of directories representing the header of the input
source (if using @strong{--header :}) or the number of the input source and
corresponding values.

@emph{prefix} can contain replacement strings.

E.g:

@verbatim
  parallel --header : --results foo echo {a} {b} \
    ::: a I II ::: b III IIII
@end verbatim

will generate the files:

@verbatim
  foo/a/I/b/III/stderr
  foo/a/I/b/III/stdout
  foo/a/I/b/IIII/stderr
  foo/a/I/b/IIII/stdout
  foo/a/II/b/III/stderr
  foo/a/II/b/III/stdout
  foo/a/II/b/IIII/stderr
  foo/a/II/b/IIII/stdout
@end verbatim

and

@verbatim
  parallel --results foo echo {1} {2} ::: I II ::: III IIII
@end verbatim

will generate the files:

@verbatim
  foo/1/I/2/III/stderr
  foo/1/I/2/III/stdout
  foo/1/I/2/IIII/stderr
  foo/1/I/2/IIII/stdout
  foo/1/II/2/III/stderr
  foo/1/II/2/III/stdout
  foo/1/II/2/IIII/stderr
  foo/1/II/2/IIII/stdout
@end verbatim

and

@verbatim
  parallel --results foo-{1} echo {1} {2} ::: I II ::: III IIII
@end verbatim

will generate the files:

@verbatim
  foo-I/1/I/2/IIII/seq
  foo-I/1/I/2/IIII/stderr
  foo-I/1/I/2/IIII/stdout
  foo-I/1/I/2/III/seq
  foo-I/1/I/2/III/stderr
  foo-I/1/I/2/III/stdout
  foo-II/1/II/2/IIII/seq
  foo-II/1/II/2/IIII/stderr
  foo-II/1/II/2/IIII/stdout
  foo-II/1/II/2/III/seq
  foo-II/1/II/2/III/stderr
  foo-II/1/II/2/III/stdout
@end verbatim

If you do not want the dir structure, try @strong{--files} @strong{--tag} instead.

See also @strong{--files}, @strong{--tag}, @strong{--header}, @strong{--joblog}.

@item @strong{--resume}
@anchor{@strong{--resume}}

Resumes from the last unfinished job. By reading @strong{--joblog} or the
@strong{--results} dir GNU @strong{parallel} will figure out the last unfinished
job and continue from there. As GNU @strong{parallel} only looks at the
sequence numbers in @strong{--joblog} then the input, the command, and
@strong{--joblog} all have to remain unchanged; otherwise GNU @strong{parallel}
may run wrong commands.

See also @strong{--joblog}, @strong{--results}, @strong{--resume-failed}, @strong{--retries}.

@item @strong{--resume-failed}
@anchor{@strong{--resume-failed}}

Retry all failed and resume from the last unfinished job. By reading
@strong{--joblog} GNU @strong{parallel} will figure out the failed jobs and run
those again. After that it will resume last unfinished job and
continue from there. As GNU @strong{parallel} only looks at the sequence
numbers in @strong{--joblog} then the input, the command, and @strong{--joblog}
all have to remain unchanged; otherwise GNU @strong{parallel} may run wrong
commands.

See also @strong{--joblog}, @strong{--resume}, @strong{--retry-failed}, @strong{--retries}.

@item @strong{--retry-failed}
@anchor{@strong{--retry-failed}}

Retry all failed jobs in joblog. By reading @strong{--joblog} GNU
@strong{parallel} will figure out the failed jobs and run those again.

@strong{--retry-failed} ignores the command and arguments on the command
line: It only looks at the joblog.

@verbatim
    B<Differences between --resume, --resume-failed, --retry-failed>
@end verbatim

In this example @strong{exit @{= $_%=2 =@}} will cause every other job to fail.

@verbatim
  timeout -k 1 4 parallel --joblog log -j10 'sleep {}; exit {= $_%=2 =}' ::: {10..1}
@end verbatim

4 jobs completed. 2 failed:

@verbatim
  Seq   [...]   Exitval Signal  Command
  10    [...]   1       0       sleep 1; exit 1
  9     [...]   0       0       sleep 2; exit 0
  8     [...]   1       0       sleep 3; exit 1
  7     [...]   0       0       sleep 4; exit 0
@end verbatim

@strong{--resume} does not care about the Exitval, but only looks at Seq. If
the Seq is run, it will not be run again. So if needed, you can change
the command for the seqs not run yet:

@verbatim
  parallel --resume --joblog log -j10 'sleep .{}; exit {= $_%=2 =}' ::: {10..1}

  Seq   [...]   Exitval Signal  Command
  [... as above ...]
  1     [...]   0       0       sleep .10; exit 0
  6     [...]   1       0       sleep .5; exit 1
  5     [...]   0       0       sleep .6; exit 0
  4     [...]   1       0       sleep .7; exit 1
  3     [...]   0       0       sleep .8; exit 0
  2     [...]   1       0       sleep .9; exit 1
@end verbatim

@strong{--resume-failed} cares about the Exitval, but also only looks at Seq
to figure out which commands to run. Again this means you can change
the command, but not the arguments. It will run the failed seqs and
the seqs not yet run:

@verbatim
  parallel --resume-failed --joblog log -j10 'echo {};sleep .{}; exit {= $_%=3 =}' ::: {10..1}

  Seq   [...]   Exitval Signal  Command
  [... as above ...]
  10    [...]   1       0       echo 1;sleep .1; exit 1
  8     [...]   0       0       echo 3;sleep .3; exit 0
  6     [...]   2       0       echo 5;sleep .5; exit 2
  4     [...]   1       0       echo 7;sleep .7; exit 1
  2     [...]   0       0       echo 9;sleep .9; exit 0
@end verbatim

@strong{--retry-failed} cares about the Exitval, but takes the command from
the joblog. It ignores any arguments or commands given on the command
line:

@verbatim
  parallel --retry-failed --joblog log -j10 this part is ignored

  Seq   [...]   Exitval Signal  Command
  [... as above ...]
  10    [...]   1       0       echo 1;sleep .1; exit 1
  6     [...]   2       0       echo 5;sleep .5; exit 2
  4     [...]   1       0       echo 7;sleep .7; exit 1
@end verbatim

See also @strong{--joblog}, @strong{--resume}, @strong{--resume-failed}, @strong{--retries}.

@item @strong{--retries} @emph{n}
@anchor{@strong{--retries} @emph{n}}

If a job fails, retry it on another computer on which it has not
failed. Do this @emph{n} times. If there are fewer than @emph{n} computers in
@strong{--sshlogin} GNU @strong{parallel} will re-use all the computers. This is
useful if some jobs fail for no apparent reason (such as network
failure).

@item @strong{--return} @emph{filename}
@anchor{@strong{--return} @emph{filename}}

Transfer files from remote computers. @strong{--return} is used with
@strong{--sshlogin} when the arguments are files on the remote computers. When
processing is done the file @emph{filename} will be transferred
from the remote computer using @strong{rsync} and will be put relative to
the default login dir. E.g.

@verbatim
  echo foo/bar.txt | parallel --return {.}.out \
    --sshlogin server.example.com touch {.}.out
@end verbatim

This will transfer the file @emph{$HOME/foo/bar.out} from the computer
@emph{server.example.com} to the file @emph{foo/bar.out} after running
@strong{touch foo/bar.out} on @emph{server.example.com}.

@verbatim
  parallel -S server --trc out/./{}.out touch {}.out ::: in/file
@end verbatim

This will transfer the file @emph{in/file.out} from the computer
@emph{server.example.com} to the files @emph{out/in/file.out} after running
@strong{touch in/file.out} on @emph{server}.

@verbatim
  echo /tmp/foo/bar.txt | parallel --return {.}.out \
    --sshlogin server.example.com touch {.}.out
@end verbatim

This will transfer the file @emph{/tmp/foo/bar.out} from the computer
@emph{server.example.com} to the file @emph{/tmp/foo/bar.out} after running
@strong{touch /tmp/foo/bar.out} on @emph{server.example.com}.

Multiple files can be transferred by repeating the option multiple
times:

@verbatim
  echo /tmp/foo/bar.txt | parallel \
    --sshlogin server.example.com \
    --return {.}.out --return {.}.out2 touch {.}.out {.}.out2
@end verbatim

@strong{--return} is often used with @strong{--transferfile} and @strong{--cleanup}.

@strong{--return} is ignored when used with @strong{--sshlogin :} or when not used
with @strong{--sshlogin}.

@item @strong{--round-robin}
@anchor{@strong{--round-robin}}

@item @strong{--round}
@anchor{@strong{--round}}

Normally @strong{--pipe} will give a single block to each instance of the
command. With @strong{--round-robin} all blocks will at random be written to
commands already running. This is useful if the command takes a long
time to initialize.

@strong{--keep-order} will not work with @strong{--round-robin} as it is
impossible to track which input block corresponds to which output.

@strong{--round-robin} implies @strong{--pipe}, except if @strong{--pipepart} is given.

@item @strong{--rpl} '@emph{tag} @emph{perl expression}'
@anchor{@strong{--rpl} '@emph{tag} @emph{perl expression}'}

Use @emph{tag} as a replacement string for @emph{perl expression}. This makes
it possible to define your own replacement strings. GNU @strong{parallel}'s
7 replacement strings are implemented as:

@verbatim
  --rpl '{} '
  --rpl '{#} 1 $_=$job->seq()'
  --rpl '{%} 1 $_=$job->slot()'
  --rpl '{/} s:.*/::'
  --rpl '{//} $Global::use{"File::Basename"} ||= eval "use File::Basename; 1;"; $_ = dirname($_);'
  --rpl '{/.} s:.*/::; s:\.[^/.]+$::;'
  --rpl '{.} s:\.[^/.]+$::'
@end verbatim

The @strong{--plus} replacement strings are implemented as:

@verbatim
  --rpl '{+/} s:/[^/]*$::'
  --rpl '{+.} s:.*\.::'
  --rpl '{+..} s:.*\.([^.]*\.):$1:'
  --rpl '{+...} s:.*\.([^.]*\.[^.]*\.):$1:'
  --rpl '{..} s:\.[^/.]+$::; s:\.[^/.]+$::'
  --rpl '{...} s:\.[^/.]+$::; s:\.[^/.]+$::; s:\.[^/.]+$::'
  --rpl '{/..} s:.*/::; s:\.[^/.]+$::; s:\.[^/.]+$::'
  --rpl '{/...} s:.*/::; s:\.[^/.]+$::; s:\.[^/.]+$::; s:\.[^/.]+$::'
  --rpl '{##} $_=total_jobs()'
@end verbatim

If the user defined replacement string starts with '@{' it can also be
used as a positional replacement string (like @strong{@{2.@}}).

It is recommended to only change $_ but you have full access to all
of GNU @strong{parallel}'s internal functions and data structures.

Here are a few examples:

@verbatim
  Is the job sequence even or odd?
  --rpl '{odd} $_ = $job->seq() % 2 ? "odd" : "even"'
  Pad job sequence with leading zeros to get equal width
  --rpl '{0#} $f = "%0".int(1+log(total_jobs())/log(10))."d"; $_=sprintf($f,$job->seq())'
  Job sequence counting from 0
  --rpl '{#0} $_ = $job->seq() - 1'
  Job slot counting from 2
  --rpl '{%1} $_ = $job->slot() + 1'
@end verbatim

See also: @strong{@{= perl expression =@}} @strong{--parens}

@item @strong{--max-chars}=@emph{max-chars}
@anchor{@strong{--max-chars}=@emph{max-chars}}

@item @strong{-s} @emph{max-chars}
@anchor{@strong{-s} @emph{max-chars}}

Use at most @emph{max-chars} characters per command line, including the
command and initial-arguments and the terminating nulls at the ends of
the argument strings.  The largest allowed value is system-dependent,
and is calculated as the argument length limit for exec, less the size
of your environment.  The default value is the maximum.

Implies @strong{-X} unless @strong{-m} is set.

@item @strong{--show-limits}
@anchor{@strong{--show-limits}}

Display the limits on the command-line length which are imposed by the
operating system and the @strong{-s} option.  Pipe the input from /dev/null
(and perhaps specify --no-run-if-empty) if you don't want GNU @strong{parallel}
to do anything.

@item @strong{--semaphore}
@anchor{@strong{--semaphore}}

Work as a counting semaphore. @strong{--semaphore} will cause GNU
@strong{parallel} to start @emph{command} in the background. When the number of
jobs given by @strong{--jobs} is reached, GNU @strong{parallel} will wait for one of
these to complete before starting another command.

@strong{--semaphore} implies @strong{--bg} unless @strong{--fg} is specified.

@strong{--semaphore} implies @strong{--semaphorename `tty`} unless
@strong{--semaphorename} is specified.

Used with @strong{--fg}, @strong{--wait}, and @strong{--semaphorename}.

The command @strong{sem} is an alias for @strong{parallel --semaphore}.

See also @strong{man sem}.

@item @strong{--semaphorename} @emph{name}
@anchor{@strong{--semaphorename} @emph{name}}

@item @strong{--id} @emph{name}
@anchor{@strong{--id} @emph{name}}

Use @strong{name} as the name of the semaphore. Default is the name of the
controlling tty (output from @strong{tty}).

The default normally works as expected when used interactively, but
when used in a script @emph{name} should be set. @emph{$$} or @emph{my_task_name}
are often a good value.

The semaphore is stored in ~/.parallel/semaphores/

Implies @strong{--semaphore}.

See also @strong{man sem}.

@item @strong{--semaphoretimeout} @emph{secs}
@anchor{@strong{--semaphoretimeout} @emph{secs}}

@item @strong{--st} @emph{secs}
@anchor{@strong{--st} @emph{secs}}

If @emph{secs} > 0: If the semaphore is not released within @emph{secs} seconds, take it anyway.

If @emph{secs} < 0: If the semaphore is not released within @emph{secs} seconds, exit.

Implies @strong{--semaphore}.

See also @strong{man sem}.

@item @strong{--seqreplace} @emph{replace-str}
@anchor{@strong{--seqreplace} @emph{replace-str}}

Use the replacement string @emph{replace-str} instead of @strong{@{#@}} for
job sequence number.

@item @strong{--shebang}
@anchor{@strong{--shebang}}

@item @strong{--hashbang}
@anchor{@strong{--hashbang}}

GNU @strong{parallel} can be called as a shebang (#!) command as the first
line of a script. The content of the file will be treated as
inputsource.

Like this:

@verbatim
  #!/usr/bin/parallel --shebang -r traceroute

  qubes-os.org
  debian.org
  freenetproject.org
@end verbatim

@strong{--shebang} must be set as the first option.

On FreeBSD @strong{env} is needed:

@verbatim
  #!/usr/bin/env -S parallel --shebang -r traceroute

  qubes-os.org
  debian.org
  freenetproject.org
@end verbatim

There are many limitations of shebang (#!) depending on your operating
system. See details on http://www.in-ulm.de/~mascheck/various/shebang/

@item @strong{--shebang-wrap}
@anchor{@strong{--shebang-wrap}}

GNU @strong{parallel} can parallelize scripts by wrapping the shebang
line. If the program can be run like this:

@verbatim
  cat arguments | parallel the_program
@end verbatim

then the script can be changed to:

@verbatim
  #!/usr/bin/parallel --shebang-wrap /the/original/parser --with-options
@end verbatim

E.g.

@verbatim
  #!/usr/bin/parallel --shebang-wrap /usr/bin/python
@end verbatim

If the program can be run like this:

@verbatim
  cat data | parallel --pipe the_program
@end verbatim

then the script can be changed to:

@verbatim
  #!/usr/bin/parallel --shebang-wrap --pipe /the/original/parser --with-options
@end verbatim

E.g.

@verbatim
  #!/usr/bin/parallel --shebang-wrap --pipe /usr/bin/perl -w
@end verbatim

@strong{--shebang-wrap} must be set as the first option.

@item @strong{--shellquote}
@anchor{@strong{--shellquote}}

Does not run the command but quotes it. Useful for making quoted
composed commands for GNU @strong{parallel}.

@item @strong{--shuf}
@anchor{@strong{--shuf}}

Shuffle jobs. When having multiple input sources it is hard to
randomize jobs. --shuf will generate all jobs, and shuffle them before
running them. This is useful to get a quick preview of the results
before running the full batch.

@item @strong{--skip-first-line}
@anchor{@strong{--skip-first-line}}

Do not use the first line of input (used by GNU @strong{parallel} itself
when called with @strong{--shebang}).

@item @strong{--sql} @emph{DBURL} (obsolete)
@anchor{@strong{--sql} @emph{DBURL} (obsolete)}

Use @strong{--sqlmaster} instead.

@item @strong{--sqlmaster} @emph{DBURL}
@anchor{@strong{--sqlmaster} @emph{DBURL}}

Submit jobs via SQL server. @emph{DBURL} must point to a table, which will
contain the same information as @strong{--joblog}, the values from the input
sources (stored in columns V1 .. Vn), and the output (stored in
columns Stdout and Stderr).

The table will be dropped and created with the correct amount of
V-columns.

@strong{--sqlmaster} does not run any jobs, but it creates the values for
the jobs to be run and wait for them to complete. One or more
@strong{--sqlworker} must be run to actually execute the jobs.

The format of a DBURL is:

@verbatim
  [sql:]vendor://[[user][:password]@][host][:port]/[database]/table
@end verbatim

E.g.

@verbatim
  sql:mysql://hr:hr@localhost:3306/hrdb/jobs
  mysql://scott:tiger@my.example.com/pardb/paralleljobs
  sql:oracle://scott:tiger@ora.example.com/xe/parjob
  postgresql://scott:tiger@pg.example.com/pgdb/parjob
  pg:///parjob
  sqlite3:///pardb/parjob
@end verbatim

It can also be an alias from ~/.sql/aliases:

@verbatim
  :myalias mysql:///mydb/paralleljobs
@end verbatim

@item @strong{--sqlandworker} @emph{DBURL}
@anchor{@strong{--sqlandworker} @emph{DBURL}}

Shorthand for: @strong{--sqlmaster} @emph{DBURL} @strong{--sqlworker} @emph{DBURL}.

@item @strong{--sqlworker} @emph{DBURL}
@anchor{@strong{--sqlworker} @emph{DBURL}}

Execute jobs via SQL server. Read the input sources variables from the
table pointed to by @emph{DBURL}. The @emph{command} on the command line
should be the same as given by @strong{--sqlmaster}.

@item @strong{--ssh} @emph{sshcommand}
@anchor{@strong{--ssh} @emph{sshcommand}}

GNU @strong{parallel} defaults to using @strong{ssh} for remote access. This can
be overridden with @strong{--ssh}. It can also be set on a per server
basis (see @strong{--sshlogin}).

@item @strong{--sshdelay} @emph{secs}
@anchor{@strong{--sshdelay} @emph{secs}}

Delay starting next ssh by @emph{secs} seconds. GNU @strong{parallel} will pause
@emph{secs} seconds after starting each ssh. @emph{secs} can be less than 1
seconds.

@item @strong{-S} @emph{[@@hostgroups/][ncpu/]sshlogin[,[@@hostgroups/][ncpu/]sshlogin[,...]]}
@anchor{@strong{-S} @emph{[@@hostgroups/][ncpu/]sshlogin[@comma{}[@@hostgroups/][ncpu/]sshlogin[@comma{}...]]}}

@item @strong{-S} @emph{@@hostgroup}
@anchor{@strong{-S} @emph{@@hostgroup}}

@item @strong{--sshlogin} @emph{[@@hostgroups/][ncpu/]sshlogin[,[@@hostgroups/][ncpu/]sshlogin[,...]]}
@anchor{@strong{--sshlogin} @emph{[@@hostgroups/][ncpu/]sshlogin[@comma{}[@@hostgroups/][ncpu/]sshlogin[@comma{}...]]}}

@item @strong{--sshlogin} @emph{@@hostgroup}
@anchor{@strong{--sshlogin} @emph{@@hostgroup}}

Distribute jobs to remote computers. The jobs will be run on a list of
remote computers.

If @emph{hostgroups} is given, the @emph{sshlogin} will be added to that
hostgroup. Multiple hostgroups are separated by '+'. The @emph{sshlogin}
will always be added to a hostgroup named the same as @emph{sshlogin}.

If only the @emph{@@hostgroup} is given, only the sshlogins in that
hostgroup will be used. Multiple @emph{@@hostgroup} can be given.

GNU @strong{parallel} will determine the number of CPU cores on the remote
computers and run the number of jobs as specified by @strong{-j}.  If the
number @emph{ncpu} is given GNU @strong{parallel} will use this number for
number of CPU cores on the host. Normally @emph{ncpu} will not be needed.

An @emph{sshlogin} is of the form:

@verbatim
  [sshcommand [options]] [username@]hostname
@end verbatim

The sshlogin must not require a password (@strong{ssh-agent},
@strong{ssh-copy-id}, and @strong{sshpass} may help with that).

The sshlogin ':' is special, it means 'no ssh' and will therefore run
on the local computer.

The sshlogin '..' is special, it read sshlogins from ~/.parallel/sshloginfile

The sshlogin '-' is special, too, it read sshlogins from stdin
(standard input).

To specify more sshlogins separate the sshlogins by comma, newline (in
the same string), or repeat the options multiple times.

For examples: see @strong{--sshloginfile}.

The remote host must have GNU @strong{parallel} installed.

@strong{--sshlogin} is known to cause problems with @strong{-m} and @strong{-X}.

@strong{--sshlogin} is often used with @strong{--transferfile}, @strong{--return},
@strong{--cleanup}, and @strong{--trc}.

@item @strong{--sshloginfile} @emph{filename}
@anchor{@strong{--sshloginfile} @emph{filename}}

@item @strong{--slf} @emph{filename}
@anchor{@strong{--slf} @emph{filename}}

File with sshlogins. The file consists of sshlogins on separate
lines. Empty lines and lines starting with '#' are ignored. Example:

@verbatim
  server.example.com
  username@server2.example.com
  8/my-8-core-server.example.com
  2/my_other_username@my-dualcore.example.net
  # This server has SSH running on port 2222
  ssh -p 2222 server.example.net
  4/ssh -p 2222 quadserver.example.net
  # Use a different ssh program
  myssh -p 2222 -l myusername hexacpu.example.net
  # Use a different ssh program with default number of cores
  //usr/local/bin/myssh -p 2222 -l myusername hexacpu
  # Use a different ssh program with 6 cores
  6//usr/local/bin/myssh -p 2222 -l myusername hexacpu
  # Assume 16 cores on the local computer
  16/:
  # Put server1 in hostgroup1
  @hostgroup1/server1
  # Put myusername@server2 in hostgroup1+hostgroup2
  @hostgroup1+hostgroup2/myusername@server2
  # Force 4 cores and put 'ssh -p 2222 server3' in hostgroup1
  @hostgroup1/4/ssh -p 2222 server3
@end verbatim

When using a different ssh program the last argument must be the hostname.

Multiple @strong{--sshloginfile} are allowed.

GNU @strong{parallel} will first look for the file in current dir; if that
fails it look for the file in ~/.parallel.

The sshloginfile '..' is special, it read sshlogins from
~/.parallel/sshloginfile

The sshloginfile '.' is special, it read sshlogins from
/etc/parallel/sshloginfile

The sshloginfile '-' is special, too, it read sshlogins from stdin
(standard input).

If the sshloginfile is changed it will be re-read when a job finishes
though at most once per second. This makes it possible to add and
remove hosts while running.

This can be used to have a daemon that updates the sshloginfile to
only contain servers that are up:

@verbatim
    cp original.slf tmp2.slf
    while [ 1 ] ; do
      nice parallel --nonall -j0 -k --slf original.slf \
        --tag echo | perl 's/\t$//' > tmp.slf
      if diff tmp.slf tmp2.slf; then
        mv tmp.slf tmp2.slf
      fi
      sleep 10
    done &
    parallel --slf tmp2.slf ...
@end verbatim

@item @strong{--slotreplace} @emph{replace-str}
@anchor{@strong{--slotreplace} @emph{replace-str}}

Use the replacement string @emph{replace-str} instead of @strong{@{%@}} for
job slot number.

@item @strong{--silent}
@anchor{@strong{--silent}}

Silent.  The job to be run will not be printed. This is the default.
Can be reversed with @strong{-v}.

@item @strong{--tty}
@anchor{@strong{--tty}}

Open terminal tty. If GNU @strong{parallel} is used for starting an
interactive program then this option may be needed. It will start only
one job at a time (i.e. @strong{-j1}), not buffer the output (i.e. @strong{-u}),
and it will open a tty for the job. When the job is done, the next job
will get the tty.

You can of course override @strong{-j1} and @strong{-u}.

@item @strong{--tag}
@anchor{@strong{--tag}}

Tag lines with arguments. Each output line will be prepended with the
arguments and TAB (\t). When combined with @strong{--onall} or @strong{--nonall}
the lines will be prepended with the sshlogin instead.

@strong{--tag} is ignored when using @strong{-u}.

@item @strong{--tagstring} @emph{str}
@anchor{@strong{--tagstring} @emph{str}}

Tag lines with a string. Each output line will be prepended with
@emph{str} and TAB (\t). @emph{str} can contain replacement strings such as
@strong{@{@}}.

@strong{--tagstring} is ignored when using @strong{-u}, @strong{--onall}, and @strong{--nonall}.

@item @strong{--termseq} @emph{sequence}
@anchor{@strong{--termseq} @emph{sequence}}

Termination sequence. When a job is killed due to @strong{--timeout},
@strong{--memfree}, @strong{--halt}, or abnormal termination of GNU @strong{parallel},
@emph{sequence} determines how the job is killed. The default is:

@verbatim
    TERM,200,TERM,100,TERM,50,KILL,25
@end verbatim

which sends a TERM signal, waits 200 ms, sends another TERM signal,
waits 100 ms, sends another TERM signal, waits 50 ms, sends a KILL
signal, waits 25 ms, and exits. GNU @strong{parallel} discovers if a process
dies before the waiting time is up.

@item @strong{--tmpdir} @emph{dirname}
@anchor{@strong{--tmpdir} @emph{dirname}}

Directory for temporary files. GNU @strong{parallel} normally buffers output
into temporary files in /tmp. By setting @strong{--tmpdir} you can use a
different dir for the files. Setting @strong{--tmpdir} is equivalent to
setting $TMPDIR.

@item @strong{--tmux}
@anchor{@strong{--tmux}}

Use @strong{tmux} for output. Start a @strong{tmux} session and run each job in a
window in that session. No other output will be produced.

@item @strong{--tmuxpane}
@anchor{@strong{--tmuxpane}}

Use @strong{tmux} for output but put output into panes in the first window.
Useful if you want to monitor the progress of less than 100 concurrent
jobs.

@item @strong{--timeout} @emph{secs}
@anchor{@strong{--timeout} @emph{secs}}

Time out for command. If the command runs for longer than @emph{secs}
seconds it will get killed with SIGTERM, followed by SIGTERM 200 ms
later, followed by SIGKILL 200 ms later.

If @emph{secs} is followed by a % then the timeout will dynamically be
computed as a percentage of the median average runtime. Only values
> 100% will make sense.

@item @strong{--verbose}
@anchor{@strong{--verbose}}

@item @strong{-t}
@anchor{@strong{-t}}

Print the job to be run on stderr (standard error).

See also @strong{-v}, @strong{-p}.

@item @strong{--transfer}
@anchor{@strong{--transfer}}

Transfer files to remote computers. Shorthand for: @strong{--transferfile @{@}}.

@item @strong{--transferfile} @emph{filename}
@anchor{@strong{--transferfile} @emph{filename}}

@item @strong{--tf} @emph{filename}
@anchor{@strong{--tf} @emph{filename}}

@strong{--transferfile} is used with @strong{--sshlogin} to transfer files to the
remote computers. The files will be transferred using @strong{rsync} and
will be put relative to the default work dir. If the path contains /./
the remaining path will be relative to the work dir. E.g.

@verbatim
  echo foo/bar.txt | parallel \
    --sshlogin server.example.com --transferfile {} wc
@end verbatim

This will transfer the file @emph{foo/bar.txt} to the computer
@emph{server.example.com} to the file @emph{$HOME/foo/bar.txt} before running
@strong{wc foo/bar.txt} on @emph{server.example.com}.

@verbatim
  echo /tmp/foo/bar.txt | parallel \
    --sshlogin server.example.com --transferfile {} wc
@end verbatim

This will transfer the file @emph{/tmp/foo/bar.txt} to the computer
@emph{server.example.com} to the file @emph{/tmp/foo/bar.txt} before running
@strong{wc /tmp/foo/bar.txt} on @emph{server.example.com}.

@verbatim
  echo /tmp/./foo/bar.txt | parallel \
    --sshlogin server.example.com --transferfile {} wc {= s:.*/./:./: =}
@end verbatim

This will transfer the file @emph{/tmp/foo/bar.txt} to the computer
@emph{server.example.com} to the file @emph{foo/bar.txt} before running
@strong{wc ./foo/bar.txt} on @emph{server.example.com}.

@strong{--transferfile} is often used with @strong{--return} and @strong{--cleanup}. A
shorthand for @strong{--transferfile @{@}} is @strong{--transfer}.

@strong{--transferfile} is ignored when used with @strong{--sshlogin :} or when
not used with @strong{--sshlogin}.

@item @strong{--trc} @emph{filename}
@anchor{@strong{--trc} @emph{filename}}

Transfer, Return, Cleanup. Shorthand for:

@strong{--transferfile @{@}} @strong{--return} @emph{filename} @strong{--cleanup}

@item @strong{--trim} <n|l|r|lr|rl>
@anchor{@strong{--trim} <n|l|r|lr|rl>}

Trim white space in input.

@table @asis
@item n
@anchor{n}

No trim. Input is not modified. This is the default.

@item l
@anchor{l}

Left trim. Remove white space from start of input. E.g. " a bc " -> "a bc ".

@item r
@anchor{r}

Right trim. Remove white space from end of input. E.g. " a bc " -> " a bc".

@item lr
@anchor{lr}

@item rl
@anchor{rl}

Both trim. Remove white space from both start and end of input. E.g. "
a bc " -> "a bc". This is the default if @strong{--colsep} is used.

@end table

@item @strong{--ungroup}
@anchor{@strong{--ungroup}}

@item @strong{-u}
@anchor{@strong{-u}}

Ungroup output.  Output is printed as soon as possible and by passes
GNU @strong{parallel} internal processing. This may cause output from
different commands to be mixed thus should only be used if you do not
care about the output. Compare these:

@verbatim
  seq 4 | parallel -j0 \
    'sleep {};echo -n start{};sleep {};echo {}end'
  seq 4 | parallel -u -j0 \
    'sleep {};echo -n start{};sleep {};echo {}end'
@end verbatim

It also disables @strong{--tag}. GNU @strong{parallel} outputs faster with
@strong{-u}. Compare the speed of these:

@verbatim
  parallel seq ::: 300000000 >/dev/null
  parallel -u seq ::: 300000000 >/dev/null
  parallel --line-buffer seq ::: 300000000 >/dev/null
@end verbatim

Can be reversed with @strong{--group}.

See also: @strong{--line-buffer} @strong{--group}

@item @strong{--extensionreplace} @emph{replace-str}
@anchor{@strong{--extensionreplace} @emph{replace-str}}

@item @strong{--er} @emph{replace-str}
@anchor{@strong{--er} @emph{replace-str}}

Use the replacement string @emph{replace-str} instead of @strong{@{.@}} for input
line without extension.

@item @strong{--use-cpus-instead-of-cores}
@anchor{@strong{--use-cpus-instead-of-cores}}

Count the number of physical CPUs instead of CPU cores. When computing
how many jobs to run simultaneously relative to the number of CPU cores
you can ask GNU @strong{parallel} to instead look at the number of physical
CPUs. This will make sense for computers that have hyperthreading as
two jobs running on one CPU with hyperthreading will run slower than
two jobs running on two physical CPUs. Some multi-core CPUs can run
faster if only one thread is running per physical CPU. Most users will
not need this option.

@item @strong{-v}
@anchor{@strong{-v}}

Verbose.  Print the job to be run on stdout (standard output). Can be reversed
with @strong{--silent}. See also @strong{-t}.

Use @strong{-v} @strong{-v} to print the wrapping ssh command when running remotely.

@item @strong{--version}
@anchor{@strong{--version}}

@item @strong{-V}
@anchor{@strong{-V}}

Print the version GNU @strong{parallel} and exit.

@item @strong{--workdir} @emph{mydir}
@anchor{@strong{--workdir} @emph{mydir}}

@item @strong{--wd} @emph{mydir}
@anchor{@strong{--wd} @emph{mydir}}

Files transferred using @strong{--transferfile} and @strong{--return} will be
relative to @emph{mydir} on remote computers, and the command will be
executed in the dir @emph{mydir}.

The special @emph{mydir} value @strong{...} will create working dirs under
@strong{~/.parallel/tmp/} on the remote computers. If @strong{--cleanup} is given
these dirs will be removed.

The special @emph{mydir} value @strong{.} uses the current working dir.  If the
current working dir is beneath your home dir, the value @strong{.} is
treated as the relative path to your home dir. This means that if your
home dir is different on remote computers (e.g. if your login is
different) the relative path will still be relative to your home dir.

To see the difference try:

@verbatim
  parallel -S server pwd ::: ""
  parallel --wd . -S server pwd ::: ""
  parallel --wd ... -S server pwd ::: ""
@end verbatim

@emph{mydir} can contain GNU @strong{parallel}'s replacement strings.

@item @strong{--wait}
@anchor{@strong{--wait}}

Wait for all commands to complete.

Implies @strong{--semaphore}.

See also @strong{man sem}.

@item @strong{-X}
@anchor{@strong{-X}}

Multiple arguments with context replace. Insert as many arguments as
the command line length permits. If multiple jobs are being run in
parallel: distribute the arguments evenly among the jobs. Use @strong{-j1}
to avoid this.

If @strong{@{@}} is not used the arguments will be appended to the line.  If
@strong{@{@}} is used as part of a word (like @emph{pic@{@}.jpg}) then the whole
word will be repeated. If @strong{@{@}} is used multiple times each @strong{@{@}} will
be replaced with the arguments.

Normally @strong{-X} will do the right thing, whereas @strong{-m} can give
unexpected results if @strong{@{@}} is used as part of a word.

Support for @strong{-X} with @strong{--sshlogin} is limited and may fail.

See also @strong{-m}.

@item @strong{--exit}
@anchor{@strong{--exit}}

@item @strong{-x}
@anchor{@strong{-x}}

Exit if the size (see the @strong{-s} option) is exceeded.

@end table

@node EXAMPLE: Working as xargs -n1. Argument appending
@chapter EXAMPLE: Working as xargs -n1. Argument appending

GNU @strong{parallel} can work similar to @strong{xargs -n1}.

To compress all html files using @strong{gzip} run:

@verbatim
  find . -name '*.html' | parallel gzip --best
@end verbatim

If the file names may contain a newline use @strong{-0}. Substitute FOO BAR with
FUBAR in all files in this dir and subdirs:

@verbatim
  find . -type f -print0 | parallel -q0 perl -i -pe 's/FOO BAR/FUBAR/g'
@end verbatim

Note @strong{-q} is needed because of the space in 'FOO BAR'.

@node EXAMPLE: Reading arguments from command line
@chapter EXAMPLE: Reading arguments from command line

GNU @strong{parallel} can take the arguments from command line instead of
stdin (standard input). To compress all html files in the current dir
using @strong{gzip} run:

@verbatim
  parallel gzip --best ::: *.html
@end verbatim

To convert *.wav to *.mp3 using LAME running one process per CPU core
run:

@verbatim
  parallel lame {} -o {.}.mp3 ::: *.wav
@end verbatim

@node EXAMPLE: Inserting multiple arguments
@chapter EXAMPLE: Inserting multiple arguments

When moving a lot of files like this: @strong{mv *.log destdir} you will
sometimes get the error:

@verbatim
  bash: /bin/mv: Argument list too long
@end verbatim

because there are too many files. You can instead do:

@verbatim
  ls | grep -E '\.log$' | parallel mv {} destdir
@end verbatim

This will run @strong{mv} for each file. It can be done faster if @strong{mv} gets
as many arguments that will fit on the line:

@verbatim
  ls | grep -E '\.log$' | parallel -m mv {} destdir
@end verbatim

@node EXAMPLE: Context replace
@chapter EXAMPLE: Context replace

To remove the files @emph{pict0000.jpg} .. @emph{pict9999.jpg} you could do:

@verbatim
  seq -w 0 9999 | parallel rm pict{}.jpg
@end verbatim

You could also do:

@verbatim
  seq -w 0 9999 | perl -pe 's/(.*)/pict$1.jpg/' | parallel -m rm
@end verbatim

The first will run @strong{rm} 10000 times, while the last will only run
@strong{rm} as many times needed to keep the command line length short
enough to avoid @strong{Argument list too long} (it typically runs 1-2 times).

You could also run:

@verbatim
  seq -w 0 9999 | parallel -X rm pict{}.jpg
@end verbatim

This will also only run @strong{rm} as many times needed to keep the command
line length short enough.

@node EXAMPLE: Compute intensive jobs and substitution
@chapter EXAMPLE: Compute intensive jobs and substitution

If ImageMagick is installed this will generate a thumbnail of a jpg
file:

@verbatim
  convert -geometry 120 foo.jpg thumb_foo.jpg
@end verbatim

This will run with number-of-cpu-cores jobs in parallel for all jpg
files in a directory:

@verbatim
  ls *.jpg | parallel convert -geometry 120 {} thumb_{}
@end verbatim

To do it recursively use @strong{find}:

@verbatim
  find . -name '*.jpg' | parallel convert -geometry 120 {} {}_thumb.jpg
@end verbatim

Notice how the argument has to start with @strong{@{@}} as @strong{@{@}} will include path
(e.g. running @strong{convert -geometry 120 ./foo/bar.jpg
thumb_./foo/bar.jpg} would clearly be wrong). The command will
generate files like ./foo/bar.jpg_thumb.jpg.

Use @strong{@{.@}} to avoid the extra .jpg in the file name. This command will
make files like ./foo/bar_thumb.jpg:

@verbatim
  find . -name '*.jpg' | parallel convert -geometry 120 {} {.}_thumb.jpg
@end verbatim

@node EXAMPLE: Substitution and redirection
@chapter EXAMPLE: Substitution and redirection

This will generate an uncompressed version of .gz-files next to the .gz-file:

@verbatim
  parallel zcat {} ">"{.} ::: *.gz
@end verbatim

Quoting of > is necessary to postpone the redirection. Another
solution is to quote the whole command:

@verbatim
  parallel "zcat {} >{.}" ::: *.gz
@end verbatim

Other special shell characters (such as * ; $ > < | >> <<) also need
to be put in quotes, as they may otherwise be interpreted by the shell
and not given to GNU @strong{parallel}.

@node EXAMPLE: Composed commands
@chapter EXAMPLE: Composed commands

A job can consist of several commands. This will print the number of
files in each directory:

@verbatim
  ls | parallel 'echo -n {}" "; ls {}|wc -l'
@end verbatim

To put the output in a file called <name>.dir:

@verbatim
  ls | parallel '(echo -n {}" "; ls {}|wc -l) >{}.dir'
@end verbatim

Even small shell scripts can be run by GNU @strong{parallel}:

@verbatim
  find . | parallel 'a={}; name=${a##*/};' \
    'upper=$(echo "$name" | tr "[:lower:]" "[:upper:]");'\
    'echo "$name - $upper"'

  ls | parallel 'mv {} "$(echo {} | tr "[:upper:]" "[:lower:]")"'
@end verbatim

Given a list of URLs, list all URLs that fail to download. Print the
line number and the URL.

@verbatim
  cat urlfile | parallel "wget {} 2>/dev/null || grep -n {} urlfile"
@end verbatim

Create a mirror directory with the same filenames except all files and
symlinks are empty files.

@verbatim
  cp -rs /the/source/dir mirror_dir
  find mirror_dir -type l | parallel -m rm {} '&&' touch {}
@end verbatim

Find the files in a list that do not exist

@verbatim
  cat file_list | parallel 'if [ ! -e {} ] ; then echo {}; fi'
@end verbatim

@node EXAMPLE: Composed command with multiple input sources
@chapter EXAMPLE: Composed command with multiple input sources

You have a dir with files named as 24 hours in 5 minute intervals:
00:00, 00:05, 00:10 .. 23:55. You want to find the files missing:

@verbatim
  parallel [ -f {1}:{2} ] "||" echo {1}:{2} does not exist ::: {00..23} ::: {00..55..5}
@end verbatim

@node EXAMPLE: Calling Bash functions
@chapter EXAMPLE: Calling Bash functions

If the composed command is longer than a line, it becomes hard to
read. In Bash you can use functions. Just remember to @strong{export -f} the
function.

@verbatim
  doit() {
    echo Doing it for $1
    sleep 2
    echo Done with $1
  }
  export -f doit
  parallel doit ::: 1 2 3

  doubleit() {
    echo Doing it for $1 $2
    sleep 2
    echo Done with $1 $2
  }
  export -f doubleit
  parallel doubleit ::: 1 2 3 ::: a b
@end verbatim

To do this on remote servers you need to transfer the function using
@strong{--env}:

@verbatim
  parallel --env doit -S server doit ::: 1 2 3
  parallel --env doubleit -S server doubleit ::: 1 2 3 ::: a b
@end verbatim

If your environment (aliases, variables, and functions) is small you
can copy the full environment without having to @strong{export -f}
anything. See @strong{env_parallel}.

@node EXAMPLE: Function tester
@chapter EXAMPLE: Function tester

To test a program with different parameters:

@verbatim
  tester() {
    if (eval "$@") >&/dev/null; then
      perl -e 'printf "\033[30;102m[ OK ]\033[0m @ARGV\n"' "$@"
    else
      perl -e 'printf "\033[30;101m[FAIL]\033[0m @ARGV\n"' "$@"
    fi
  }
  export -f tester
  parallel tester my_program ::: arg1 arg2
  parallel tester exit ::: 1 0 2 0
@end verbatim

If @strong{my_program} fails a red FAIL will be printed followed by the failing
command; otherwise a green OK will be printed followed by the command.

@node EXAMPLE: Log rotate
@chapter EXAMPLE: Log rotate

Log rotation renames a logfile to an extension with a higher number:
log.1 becomes log.2, log.2 becomes log.3, and so on. The oldest log is
removed. To avoid overwriting files the process starts backwards from
the high number to the low number.  This will keep 10 old versions of
the log:

@verbatim
  seq 9 -1 1 | parallel -j1 mv log.{} log.'{= $_++ =}'
  mv log log.1
@end verbatim

@node EXAMPLE: Removing file extension when processing files
@chapter EXAMPLE: Removing file extension when processing files

When processing files removing the file extension using @strong{@{.@}} is
often useful.

Create a directory for each zip-file and unzip it in that dir:

@verbatim
  parallel 'mkdir {.}; cd {.}; unzip ../{}' ::: *.zip
@end verbatim

Recompress all .gz files in current directory using @strong{bzip2} running 1
job per CPU core in parallel:

@verbatim
  parallel "zcat {} | bzip2 >{.}.bz2 && rm {}" ::: *.gz
@end verbatim

Convert all WAV files to MP3 using LAME:

@verbatim
  find sounddir -type f -name '*.wav' | parallel lame {} -o {.}.mp3
@end verbatim

Put all converted in the same directory:

@verbatim
  find sounddir -type f -name '*.wav' | \
    parallel lame {} -o mydir/{/.}.mp3
@end verbatim

@node EXAMPLE: Removing two file extensions when processing files
@chapter EXAMPLE: Removing two file extensions when processing files

If you have directory with tar.gz files and want these extracted in
the corresponding dir (e.g foo.tar.gz will be extracted in the dir
foo) you can do:

@verbatim
  parallel --plus 'mkdir {..}; tar -C {..} -xf {}' ::: *.tar.gz
@end verbatim

@node EXAMPLE: Download 24 images for each of the past 30 days
@chapter EXAMPLE: Download 24 images for each of the past 30 days

Let us assume a website stores images like:

@verbatim
  http://www.example.com/path/to/YYYYMMDD_##.jpg
@end verbatim

where YYYYMMDD is the date and ## is the number 01-24. This will
download images for the past 30 days:

@verbatim
  parallel wget http://www.example.com/path/to/'$(date -d "today -{1} days" +%Y%m%d)_{2}.jpg' ::: $(seq 30) ::: $(seq -w 24)
@end verbatim

@strong{$(date -d "today -@{1@} days" +%Y%m%d)} will give the dates in
YYYYMMDD with @strong{@{1@}} days subtracted.

@node EXAMPLE: Copy files as last modified date (ISO8601) with added random digits
@chapter EXAMPLE: Copy files as last modified date (ISO8601) with added random digits

@verbatim
  find . | parallel cp {} \
    '../destdir/{= $a=int(10000*rand); $_=`date -r "$_" +%FT%T"$a"`; chomp; =}'
@end verbatim

@strong{@{=} and @strong{=@}} mark a perl expression. @strong{date +%FT%T} is the date in ISO8601 with time.

@node EXAMPLE: Digtal clock with "blinking" :
@chapter EXAMPLE: Digtal clock with "blinking" :

The : in a digital clock blinks. To make every other line have a ':'
and the rest a ' ' a perl expression is used to look at the 3rd input
source. If the value modudo 2 is 1: Use ":" otherwise use " ":

@verbatim
  parallel -k echo {1}'{=3 $_=$_%2?":":" "=}'{2}{3} \
    ::: {0..12} ::: {0..5} ::: {0..9}
@end verbatim

@node EXAMPLE: Aggregating content of files
@chapter EXAMPLE: Aggregating content of files

This:

@verbatim
  parallel --header : echo x{X}y{Y}z{Z} \> x{X}y{Y}z{Z} \
  ::: X {1..5} ::: Y {01..10} ::: Z {1..5}
@end verbatim

will generate the files x1y01z1 .. x5y10z5. If you want to aggregate
the output grouping on x and z you can do this:

@verbatim
  parallel eval 'cat {=s/y01/y*/=} > {=s/y01//=}' ::: *y01*
@end verbatim

For all values of x and z it runs commands like:

@verbatim
  cat x1y*z1 > x1z1
@end verbatim

So you end up with x1z1 .. x5z5 each containing the content of all
values of y.

@node EXAMPLE: Breadth first parallel web crawler/mirrorer
@chapter EXAMPLE: Breadth first parallel web crawler/mirrorer

This script below will crawl and mirror a URL in parallel.  It
downloads first pages that are 1 click down, then 2 clicks down, then
3; instead of the normal depth first, where the first link link on
each page is fetched first.

Run like this:

@verbatim
  PARALLEL=-j100 ./parallel-crawl http://gatt.org.yeslab.org/
@end verbatim

Remove the @strong{wget} part if you only want a web crawler.

It works by fetching a page from a list of URLs and looking for links
in that page that are within the same starting URL and that have not
already been seen. These links are added to a new queue. When all the
pages from the list is done, the new queue is moved to the list of
URLs and the process is started over until no unseen links are found.

@verbatim
  #!/bin/bash

  # E.g. http://gatt.org.yeslab.org/
  URL=$1
  # Stay inside the start dir
  BASEURL=$(echo $URL | perl -pe 's:#.*::; s:(//.*/)[^/]*:$1:')
  URLLIST=$(mktemp urllist.XXXX)
  URLLIST2=$(mktemp urllist.XXXX)
  SEEN=$(mktemp seen.XXXX)

  # Spider to get the URLs
  echo $URL >$URLLIST
  cp $URLLIST $SEEN

  while [ -s $URLLIST ] ; do
    cat $URLLIST |
      parallel lynx -listonly -image_links -dump {} \; \
        wget -qm -l1 -Q1 {} \; echo Spidered: {} \>\&2 |
        perl -ne 's/#.*//; s/\s+\d+.\s(\S+)$/$1/ and do { $seen{$1}++ or print }' |
      grep -F $BASEURL |
      grep -v -x -F -f $SEEN | tee -a $SEEN > $URLLIST2
    mv $URLLIST2 $URLLIST
  done

  rm -f $URLLIST $URLLIST2 $SEEN
@end verbatim

@node EXAMPLE: Process files from a tar file while unpacking
@chapter EXAMPLE: Process files from a tar file while unpacking

If the files to be processed are in a tar file then unpacking one file
and processing it immediately may be faster than first unpacking all
files.

@verbatim
  tar xvf foo.tgz | perl -ne 'print $l;$l=$_;END{print $l}' | \
    parallel echo
@end verbatim

The Perl one-liner is needed to make sure the file is complete before
handing it to GNU @strong{parallel}.

@node EXAMPLE: Rewriting a for-loop and a while-read-loop
@chapter EXAMPLE: Rewriting a for-loop and a while-read-loop

for-loops like this:

@verbatim
  (for x in `cat list` ; do
    do_something $x
  done) | process_output
@end verbatim

and while-read-loops like this:

@verbatim
  cat list | (while read x ; do
    do_something $x
  done) | process_output
@end verbatim

can be written like this:

@verbatim
  cat list | parallel do_something | process_output
@end verbatim

For example: Find which host name in a list has IP address 1.2.3 4:

@verbatim
  cat hosts.txt | parallel -P 100 host | grep 1.2.3.4
@end verbatim

If the processing requires more steps the for-loop like this:

@verbatim
  (for x in `cat list` ; do
    no_extension=${x%.*};
    do_something $x scale $no_extension.jpg
    do_step2 <$x $no_extension
  done) | process_output
@end verbatim

and while-loops like this:

@verbatim
  cat list | (while read x ; do
    no_extension=${x%.*};
    do_something $x scale $no_extension.jpg
    do_step2 <$x $no_extension
  done) | process_output
@end verbatim

can be written like this:

@verbatim
  cat list | parallel "do_something {} scale {.}.jpg ; do_step2 <{} {.}" |\
    process_output
@end verbatim

If the body of the loop is bigger, it improves readability to use a function:

@verbatim
  (for x in `cat list` ; do
    do_something $x
    [... 100 lines that do something with $x ...]
  done) | process_output

  cat list | (while read x ; do
    do_something $x
    [... 100 lines that do something with $x ...]
  done) | process_output
@end verbatim

can both be rewritten as:

@verbatim
  doit() {
    x=$1
    do_something $x
    [... 100 lines that do something with $x ...]
  }
  export -f doit
  cat list | parallel doit
@end verbatim

@node EXAMPLE: Rewriting nested for-loops
@chapter EXAMPLE: Rewriting nested for-loops

Nested for-loops like this:

@verbatim
  (for x in `cat xlist` ; do
    for y in `cat ylist` ; do
      do_something $x $y
    done
  done) | process_output
@end verbatim

can be written like this:

@verbatim
  parallel do_something {1} {2} :::: xlist ylist | process_output
@end verbatim

Nested for-loops like this:

@verbatim
  (for colour in red green blue ; do
    for size in S M L XL XXL ; do
      echo $colour $size
    done
  done) | sort
@end verbatim

can be written like this:

@verbatim
  parallel echo {1} {2} ::: red green blue ::: S M L XL XXL | sort
@end verbatim

@node EXAMPLE: Finding the lowest difference between files
@chapter EXAMPLE: Finding the lowest difference between files

@strong{diff} is good for finding differences in text files. @strong{diff | wc -l}
gives an indication of the size of the difference. To find the
differences between all files in the current dir do:

@verbatim
  parallel --tag 'diff {1} {2} | wc -l' ::: * ::: * | sort -nk3
@end verbatim

This way it is possible to see if some files are closer to other
files.

@node EXAMPLE: for-loops with column names
@chapter EXAMPLE: for-loops with column names

When doing multiple nested for-loops it can be easier to keep track of
the loop variable if is is named instead of just having a number. Use
@strong{--header :} to let the first argument be an named alias for the
positional replacement string:

@verbatim
  parallel --header : echo {colour} {size} ::: colour red green blue ::: size S M L XL XXL
@end verbatim

This also works if the input file is a file with columns:

@verbatim
  cat addressbook.tsv | \
    parallel --colsep '\t' --header : echo {Name} {E-mail address}
@end verbatim

@node EXAMPLE: Count the differences between all files in a dir
@chapter EXAMPLE: Count the differences between all files in a dir

Using @strong{--results} the results are saved in /tmp/diffcount*.

@verbatim
  parallel --results /tmp/diffcount "diff -U 0 {1} {2} | \
    tail -n +3 |grep -v '^@'|wc -l" ::: * ::: *
@end verbatim

To see the difference between file A and file B look at the file
'/tmp/diffcount/1/A/2/B'.

@node EXAMPLE: Speeding up fast jobs
@chapter EXAMPLE: Speeding up fast jobs

Starting a job on the local machine takes around 10 ms. This can be a
big overhead if the job takes very few ms to run. Often you can group
small jobs together using @strong{-X} which will make the overhead less
significant. Compare the speed of these:

@verbatim
  seq -w 0 9999 | parallel touch pict{}.jpg
  seq -w 0 9999 | parallel -X touch pict{}.jpg
@end verbatim

If your program cannot take multiple arguments, then you can use GNU
@strong{parallel} to spawn multiple GNU @strong{parallel}s:

@verbatim
  seq -w 0 999999 | parallel -j10 --pipe parallel -j0 touch pict{}.jpg
@end verbatim

If @strong{-j0} normally spawns 252 jobs, then the above will try to spawn
2520 jobs. On a normal GNU/Linux system you can spawn 32000 jobs using
this technique with no problems. To raise the 32000 jobs limit raise
/proc/sys/kernel/pid_max to 4194303.

@node EXAMPLE: Using shell variables
@chapter EXAMPLE: Using shell variables

When using shell variables you need to quote them correctly as they
may otherwise be split on spaces.

Notice the difference between:

@verbatim
  V=("My brother's 12\" records are worth <\$\$\$>"'!' Foo Bar)
  parallel echo ::: ${V[@]} # This is probably not what you want
@end verbatim

and:

@verbatim
  V=("My brother's 12\" records are worth <\$\$\$>"'!' Foo Bar)
  parallel echo ::: "${V[@]}"
@end verbatim

When using variables in the actual command that contains special
characters (e.g. space) you can quote them using @strong{'"$VAR"'} or using
"'s and @strong{-q}:

@verbatim
  V="Here  are  two "
  parallel echo "'$V'" ::: spaces
  parallel -q echo "$V" ::: spaces
@end verbatim

@node EXAMPLE: Group output lines
@chapter EXAMPLE: Group output lines

When running jobs that output data, you often do not want the output
of multiple jobs to run together. GNU @strong{parallel} defaults to grouping
the output of each job, so the output is printed when the job
finishes. If you want full lines to be printed while the job is
running you can use @strong{--line-buffer}. If you want output to be
printed as soon as possible you can use @strong{-u}.

Compare the output of:

@verbatim
  parallel traceroute ::: qubes-os.org debian.org freenetproject.org
  parallel --line-buffer traceroute ::: qubes-os.org debian.org freenetproject.org
  parallel -u traceroute ::: qubes-os.org debian.org freenetproject.org
@end verbatim

@node EXAMPLE: Tag output lines
@chapter EXAMPLE: Tag output lines

GNU @strong{parallel} groups the output lines, but it can be hard to see
where the different jobs begin. @strong{--tag} prepends the argument to make
that more visible:

@verbatim
  parallel --tag traceroute ::: qubes-os.org debian.org freenetproject.org
@end verbatim

@strong{--tag} works with @strong{--line-buffer} but not with @strong{-u}:

@verbatim
  parallel --tag --line-buffer traceroute \
    ::: qubes-os.org debian.org freenetproject.org
@end verbatim

Check the uptime of the servers in @emph{~/.parallel/sshloginfile}:

@verbatim
  parallel --tag -S .. --nonall uptime
@end verbatim

@node EXAMPLE: Keep order of output same as order of input
@chapter EXAMPLE: Keep order of output same as order of input

Normally the output of a job will be printed as soon as it
completes. Sometimes you want the order of the output to remain the
same as the order of the input. This is often important, if the output
is used as input for another system. @strong{-k} will make sure the order of
output will be in the same order as input even if later jobs end
before earlier jobs.

Append a string to every line in a text file:

@verbatim
  cat textfile | parallel -k echo {} append_string
@end verbatim

If you remove @strong{-k} some of the lines may come out in the wrong order.

Another example is @strong{traceroute}:

@verbatim
  parallel traceroute ::: qubes-os.org debian.org freenetproject.org
@end verbatim

will give traceroute of qubes-os.org, debian.org and
freenetproject.org, but it will be sorted according to which job
completed first.

To keep the order the same as input run:

@verbatim
  parallel -k traceroute ::: qubes-os.org debian.org freenetproject.org
@end verbatim

This will make sure the traceroute to qubes-os.org will be printed
first.

A bit more complex example is downloading a huge file in chunks in
parallel: Some internet connections will deliver more data if you
download files in parallel. For downloading files in parallel see:
"EXAMPLE: Download 10 images for each of the past 30 days". But if you
are downloading a big file you can download the file in chunks in
parallel.

To download byte 10000000-19999999 you can use @strong{curl}:

@verbatim
  curl -r 10000000-19999999 http://example.com/the/big/file >file.part
@end verbatim

To download a 1 GB file we need 100 10MB chunks downloaded and
combined in the correct order.

@verbatim
  seq 0 99 | parallel -k curl -r \
    {}0000000-{}9999999 http://example.com/the/big/file > file
@end verbatim

@node EXAMPLE: Parallel grep
@chapter EXAMPLE: Parallel grep

@strong{grep -r} greps recursively through directories. On multicore CPUs
GNU @strong{parallel} can often speed this up.

@verbatim
  find . -type f | parallel -k -j150% -n 1000 -m grep -H -n STRING {}
@end verbatim

This will run 1.5 job per core, and give 1000 arguments to @strong{grep}.

@node EXAMPLE: Grepping n lines for m regular expressions.
@chapter EXAMPLE: Grepping n lines for m regular expressions.

The simplest solution to grep a big file for a lot of regexps is:

@verbatim
  grep -f regexps.txt bigfile
@end verbatim

Or if the regexps are fixed strings:

@verbatim
  grep -F -f regexps.txt bigfile
@end verbatim

There are 3 limiting factors: CPU, RAM, and disk I/O.

RAM is easy to measure: If the @strong{grep} process takes up most of your
free memory (e.g. when running @strong{top}), then RAM is a limiting factor.

CPU is also easy to measure: If the @strong{grep} takes >90% CPU in @strong{top},
then the CPU is a limiting factor, and parallelization will speed this
up.

It is harder to see if disk I/O is the limiting factor, and depending
on the disk system it may be faster or slower to parallelize. The only
way to know for certain is to test and measure.

@menu
* Limiting factor@asis{:} RAM::
* Limiting factor@asis{:} CPU::
* Bigger problem::
@end menu

@node Limiting factor: RAM
@section Limiting factor: RAM

The normal @strong{grep -f regexs.txt bigfile} works no matter the size of
bigfile, but if regexps.txt is so big it cannot fit into memory, then
you need to split this.

@strong{grep -F} takes around 100 bytes of RAM and @strong{grep} takes about 500
bytes of RAM per 1 byte of regexp. So if regexps.txt is 1% of your
RAM, then it may be too big.

If you can convert your regexps into fixed strings do that. E.g. if
the lines you are looking for in bigfile all looks like:

@verbatim
  ID1 foo bar baz Identifier1 quux
  fubar ID2 foo bar baz Identifier2
@end verbatim

then your regexps.txt can be converted from:

@verbatim
  ID1.*Identifier1
  ID2.*Identifier2
@end verbatim

into:

@verbatim
  ID1 foo bar baz Identifier1
  ID2 foo bar baz Identifier2
@end verbatim

This way you can use @strong{grep -F} which takes around 80% less memory and
is much faster.

If it still does not fit in memory you can do this:

@verbatim
  parallel --pipepart -a regexps.txt --block 1M grep -F -f - -n bigfile |
    sort -un | perl -pe 's/^\d+://'
@end verbatim

The 1M should be your free memory divided by the number of cores and
divided by 200 for @strong{grep -F} and by 1000 for normal @strong{grep}. On
GNU/Linux you can do:

@verbatim
  free=$(awk '/^((Swap)?Cached|MemFree|Buffers):/ { sum += $2 }
              END { print sum }' /proc/meminfo)
  percpu=$((free / 200 / $(parallel --number-of-cores)))k

  parallel --pipepart -a regexps.txt --block $percpu --compress grep -F -f - -n bigfile |
    sort -un | perl -pe 's/^\d+://'
@end verbatim

If you can live with duplicated lines and wrong order, it is faster to do:

@verbatim
  parallel --pipepart -a regexps.txt --block $percpu --compress grep -F -f - bigfile
@end verbatim

@node Limiting factor: CPU
@section Limiting factor: CPU

If the CPU is the limiting factor parallelization should be done on
the regexps:

@verbatim
  cat regexp.txt | parallel --pipe -L1000 --round-robin --compress grep -f - -n bigfile |
    sort -un | perl -pe 's/^\d+://'
@end verbatim

The command will start one @strong{grep} per CPU and read @emph{bigfile} one
time per CPU, but as that is done in parallel, all reads except the
first will be cached in RAM. Depending on the size of @emph{regexp.txt} it
may be faster to use @strong{--block 10m} instead of @strong{-L1000}.

Some storage systems perform better when reading multiple chunks in
parallel. This is true for some RAID systems and for some network file
systems. To parallelize the reading of @emph{bigfile}:

@verbatim
  parallel --pipepart --block 100M -a bigfile -k --compress grep -f regexp.txt
@end verbatim

This will split @emph{bigfile} into 100MB chunks and run @strong{grep} on each of
these chunks. To parallelize both reading of @emph{bigfile} and @emph{regexp.txt}
combine the two using @strong{--fifo}:

@verbatim
  parallel --pipepart --block 100M -a bigfile --fifo cat regexp.txt \
    \| parallel --pipe -L1000 --round-robin grep -f - {}
@end verbatim

If a line matches multiple regexps, the line may be duplicated.

@node Bigger problem
@section Bigger problem

If the problem is too big to be solved by this, you are probably ready
for Lucene.

@node EXAMPLE: Using remote computers
@chapter EXAMPLE: Using remote computers

To run commands on a remote computer SSH needs to be set up and you
must be able to login without entering a password (The commands
@strong{ssh-copy-id}, @strong{ssh-agent}, and @strong{sshpass} may help you do that).

If you need to login to a whole cluster, you typically do not want to
accept the host key for every host. You want to accept them the first
time and be warned if they are ever changed. To do that:

@verbatim
  # Add the servers to the sshloginfile
  (echo servera; echo serverb) > .parallel/my_cluster
  # Make sure .ssh/config exist
  touch .ssh/config
  cp .ssh/config .ssh/config.backup
  # Disable StrictHostKeyChecking temporarily
  (echo 'Host *'; echo StrictHostKeyChecking no) >> .ssh/config
  parallel --slf my_cluster --nonall true
  # Remove the disabling of StrictHostKeyChecking
  mv .ssh/config.backup .ssh/config
@end verbatim

The servers in @strong{.parallel/my_cluster} are now added in @strong{.ssh/known_hosts}.

To run @strong{echo} on @strong{server.example.com}:

@verbatim
  seq 10 | parallel --sshlogin server.example.com echo
@end verbatim

To run commands on more than one remote computer run:

@verbatim
  seq 10 | parallel --sshlogin server.example.com,server2.example.net echo
@end verbatim

Or:

@verbatim
  seq 10 | parallel --sshlogin server.example.com \
    --sshlogin server2.example.net echo
@end verbatim

If the login username is @emph{foo} on @emph{server2.example.net} use:

@verbatim
  seq 10 | parallel --sshlogin server.example.com \
    --sshlogin foo@server2.example.net echo
@end verbatim

If your list of hosts is @emph{server1-88.example.net} with login @emph{foo}:

@verbatim
  seq 10 | parallel -Sfoo@server{1..88}.example.net echo
@end verbatim

To distribute the commands to a list of computers, make a file
@emph{mycomputers} with all the computers:

@verbatim
  server.example.com
  foo@server2.example.com
  server3.example.com
@end verbatim

Then run:

@verbatim
  seq 10 | parallel --sshloginfile mycomputers echo
@end verbatim

To include the local computer add the special sshlogin ':' to the list:

@verbatim
  server.example.com
  foo@server2.example.com
  server3.example.com
  :
@end verbatim

GNU @strong{parallel} will try to determine the number of CPU cores on each
of the remote computers, and run one job per CPU core - even if the
remote computers do not have the same number of CPU cores.

If the number of CPU cores on the remote computers is not identified
correctly the number of CPU cores can be added in front. Here the
computer has 8 CPU cores.

@verbatim
  seq 10 | parallel --sshlogin 8/server.example.com echo
@end verbatim

@node EXAMPLE: Transferring of files
@chapter EXAMPLE: Transferring of files

To recompress gzipped files with @strong{bzip2} using a remote computer run:

@verbatim
  find logs/ -name '*.gz' | \
    parallel --sshlogin server.example.com \
    --transfer "zcat {} | bzip2 -9 >{.}.bz2"
@end verbatim

This will list the .gz-files in the @emph{logs} directory and all
directories below. Then it will transfer the files to
@emph{server.example.com} to the corresponding directory in
@emph{$HOME/logs}. On @emph{server.example.com} the file will be recompressed
using @strong{zcat} and @strong{bzip2} resulting in the corresponding file with
@emph{.gz} replaced with @emph{.bz2}.

If you want the resulting bz2-file to be transferred back to the local
computer add @emph{--return @{.@}.bz2}:

@verbatim
  find logs/ -name '*.gz' | \
    parallel --sshlogin server.example.com \
    --transfer --return {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
@end verbatim

After the recompressing is done the @emph{.bz2}-file is transferred back to
the local computer and put next to the original @emph{.gz}-file.

If you want to delete the transferred files on the remote computer add
@emph{--cleanup}. This will remove both the file transferred to the remote
computer and the files transferred from the remote computer:

@verbatim
  find logs/ -name '*.gz' | \
    parallel --sshlogin server.example.com \
    --transfer --return {.}.bz2 --cleanup "zcat {} | bzip2 -9 >{.}.bz2"
@end verbatim

If you want run on several computers add the computers to @emph{--sshlogin}
either using ',' or multiple @emph{--sshlogin}:

@verbatim
  find logs/ -name '*.gz' | \
    parallel --sshlogin server.example.com,server2.example.com \
    --sshlogin server3.example.com \
    --transfer --return {.}.bz2 --cleanup "zcat {} | bzip2 -9 >{.}.bz2"
@end verbatim

You can add the local computer using @emph{--sshlogin :}. This will disable the
removing and transferring for the local computer only:

@verbatim
  find logs/ -name '*.gz' | \
    parallel --sshlogin server.example.com,server2.example.com \
    --sshlogin server3.example.com \
    --sshlogin : \
    --transfer --return {.}.bz2 --cleanup "zcat {} | bzip2 -9 >{.}.bz2"
@end verbatim

Often @emph{--transfer}, @emph{--return} and @emph{--cleanup} are used together. They can be
shortened to @emph{--trc}:

@verbatim
  find logs/ -name '*.gz' | \
    parallel --sshlogin server.example.com,server2.example.com \
    --sshlogin server3.example.com \
    --sshlogin : \
    --trc {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
@end verbatim

With the file @emph{mycomputers} containing the list of computers it becomes:

@verbatim
  find logs/ -name '*.gz' | parallel --sshloginfile mycomputers \
    --trc {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
@end verbatim

If the file @emph{~/.parallel/sshloginfile} contains the list of computers
the special short hand @emph{-S ..} can be used:

@verbatim
  find logs/ -name '*.gz' | parallel -S .. \
    --trc {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
@end verbatim

@node EXAMPLE: Distributing work to local and remote computers
@chapter EXAMPLE: Distributing work to local and remote computers

Convert *.mp3 to *.ogg running one process per CPU core on local computer and server2:

@verbatim
  parallel --trc {.}.ogg -S server2,: \
    'mpg321 -w - {} | oggenc -q0 - -o {.}.ogg' ::: *.mp3
@end verbatim

@node EXAMPLE: Running the same command on remote computers
@chapter EXAMPLE: Running the same command on remote computers

To run the command @strong{uptime} on remote computers you can do:

@verbatim
  parallel --tag --nonall -S server1,server2 uptime
@end verbatim

@strong{--nonall} reads no arguments. If you have a list of jobs you want
run on each computer you can do:

@verbatim
  parallel --tag --onall -S server1,server2 echo ::: 1 2 3
@end verbatim

Remove @strong{--tag} if you do not want the sshlogin added before the
output.

If you have a lot of hosts use '-j0' to access more hosts in parallel.

@node EXAMPLE: Using remote computers behind NAT wall
@chapter EXAMPLE: Using remote computers behind NAT wall

If the workers are behind a NAT wall, you need some trickery to get to
them.

If you can @strong{ssh} to a jump host, and reach the workers from there,
then the obvious solution would be this, but it @strong{does not work}:

@verbatim
  parallel --ssh 'ssh jumphost ssh' -S host1 echo ::: DOES NOT WORK
@end verbatim

It does not work because the command is dequoted by @strong{ssh} twice where
as GNU @strong{parallel} only expects it to be dequoted once.

So instead put this in @strong{~/.ssh/config}:

@verbatim
  Host host1 host2 host3
    ProxyCommand ssh jumphost.domain nc -w 1 %h 22
@end verbatim

It requires @strong{nc(netcat)} to be installed on jumphost. With this you
can simply:

@verbatim
  parallel -S host1,host2,host3 echo ::: This does work
@end verbatim

@menu
* No jumphost@comma{} but port forwards::
* No jumphost@comma{} no port forwards::
@end menu

@node No jumphost@comma{} but port forwards
@section No jumphost, but port forwards

If there is no jumphost but each server has port 22 forwarded from the
firewall (e.g. the firewall's port 22001 = port 22 on host1, 22002 = host2,
22003 = host3) then you can use @strong{~/.ssh/config}:

@verbatim
  Host host1.v
    Port 22001
  Host host2.v
    Port 22002
  Host host3.v
    Port 22003
  Host *.v
    Hostname firewall
@end verbatim

And then use host@{1..3@}.v as normal hosts:

@verbatim
  parallel -S host1.v,host2.v,host3.v echo ::: a b c
@end verbatim

@node No jumphost@comma{} no port forwards
@section No jumphost, no port forwards

If ports cannot be forwarded, you need some sort of VPN to traverse
the NAT-wall. TOR is one options for that, as it is very easy to get
working.

You need to install TOR and setup a hidden service. In @strong{torrc} put:

@verbatim
  HiddenServiceDir /var/lib/tor/hidden_service/
  HiddenServicePort 22 127.0.0.1:22
@end verbatim

Then start TOR: @strong{/etc/init.d/tor restart}

The TOR hostname is now in @strong{/var/lib/tor/hidden_service/hostname} and
is something similar to @strong{izjafdceobowklhz.onion}. Now you simply
prepend @strong{torsocks} to @strong{ssh}:

@verbatim
  parallel --ssh 'torsocks ssh' -S izjafdceobowklhz.onion \
    -S zfcdaeiojoklbwhz.onion,auclucjzobowklhi.onion echo ::: a b c
@end verbatim

If not all hosts are accessible through TOR:

@verbatim
  parallel -S 'torsocks ssh izjafdceobowklhz.onion,host2,host3' echo ::: a b c
@end verbatim

See more @strong{ssh} tricks on https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies_and_Jump_Hosts

@node EXAMPLE: Parallelizing rsync
@chapter EXAMPLE: Parallelizing rsync

@strong{rsync} is a great tool, but sometimes it will not fill up the
available bandwidth. This is often a problem when copying several big
files over high speed connections.

The following will start one @strong{rsync} per big file in @emph{src-dir} to
@emph{dest-dir} on the server @emph{fooserver}:

@verbatim
  cd src-dir; find . -type f -size +100000 | \
    parallel -v ssh fooserver mkdir -p /dest-dir/{//}\; \
      rsync -s -Havessh {} fooserver:/dest-dir/{}
@end verbatim

The dirs created may end up with wrong permissions and smaller files
are not being transferred. To fix those run @strong{rsync} a final time:

@verbatim
  rsync -Havessh src-dir/ fooserver:/dest-dir/
@end verbatim

If you are unable to push data, but need to pull them and the files
are called digits.png (e.g. 000000.png) you might be able to do:

@verbatim
  seq -w 0 99 | parallel rsync -Havessh fooserver:src-path/*{}.png destdir/
@end verbatim

@node EXAMPLE: Use multiple inputs in one command
@chapter EXAMPLE: Use multiple inputs in one command

Copy files like foo.es.ext to foo.ext:

@verbatim
  ls *.es.* | perl -pe 'print; s/\.es//' | parallel -N2 cp {1} {2}
@end verbatim

The perl command spits out 2 lines for each input. GNU @strong{parallel}
takes 2 inputs (using @strong{-N2}) and replaces @{1@} and @{2@} with the inputs.

Count in binary:

@verbatim
  parallel -k echo ::: 0 1 ::: 0 1 ::: 0 1 ::: 0 1 ::: 0 1 ::: 0 1
@end verbatim

Print the number on the opposing sides of a six sided die:

@verbatim
  parallel --link -a <(seq 6) -a <(seq 6 -1 1) echo
  parallel --link echo :::: <(seq 6) <(seq 6 -1 1)
@end verbatim

Convert files from all subdirs to PNG-files with consecutive numbers
(useful for making input PNG's for @strong{ffmpeg}):

@verbatim
  parallel --link -a <(find . -type f | sort) \
    -a <(seq $(find . -type f|wc -l)) convert {1} {2}.png
@end verbatim

Alternative version:

@verbatim
  find . -type f | sort | parallel convert {} {#}.png
@end verbatim

@node EXAMPLE: Use a table as input
@chapter EXAMPLE: Use a table as input

Content of table_file.tsv:

@verbatim
  foo<TAB>bar
  baz <TAB> quux
@end verbatim

To run:

@verbatim
  cmd -o bar -i foo
  cmd -o quux -i baz
@end verbatim

you can run:

@verbatim
  parallel -a table_file.tsv --colsep '\t' cmd -o {2} -i {1}
@end verbatim

Note: The default for GNU @strong{parallel} is to remove the spaces around the columns. To keep the spaces:

@verbatim
  parallel -a table_file.tsv --trim n --colsep '\t' cmd -o {2} -i {1}
@end verbatim

@node EXAMPLE: Run the same command 10 times
@chapter EXAMPLE: Run the same command 10 times

If you want to run the same command with the same arguments 10 times
in parallel you can do:

@verbatim
  seq 10 | parallel -n0 my_command my_args
@end verbatim

@node EXAMPLE: Working as cat | sh. Resource inexpensive jobs and evaluation
@chapter EXAMPLE: Working as cat | sh. Resource inexpensive jobs and evaluation

GNU @strong{parallel} can work similar to @strong{cat | sh}.

A resource inexpensive job is a job that takes very little CPU, disk
I/O and network I/O. Ping is an example of a resource inexpensive
job. wget is too - if the webpages are small.

The content of the file jobs_to_run:

@verbatim
  ping -c 1 10.0.0.1
  wget http://example.com/status.cgi?ip=10.0.0.1
  ping -c 1 10.0.0.2
  wget http://example.com/status.cgi?ip=10.0.0.2
  ...
  ping -c 1 10.0.0.255
  wget http://example.com/status.cgi?ip=10.0.0.255
@end verbatim

To run 100 processes simultaneously do:

@verbatim
  parallel -j 100 < jobs_to_run
@end verbatim

As there is not a @emph{command} the jobs will be evaluated by the shell.

@node EXAMPLE: Processing a big file using more cores
@chapter EXAMPLE: Processing a big file using more cores

To process a big file or some output you can use @strong{--pipe} to split up
the data into blocks and pipe the blocks into the processing program.

If the program is @strong{gzip -9} you can do:

@verbatim
  cat bigfile | parallel --pipe --recend '' -k gzip -9 > bigfile.gz
@end verbatim

This will split @strong{bigfile} into blocks of 1 MB and pass that to @strong{gzip
-9} in parallel. One @strong{gzip} will be run per CPU core. The output of
@strong{gzip -9} will be kept in order and saved to @strong{bigfile.gz}

@strong{gzip} works fine if the output is appended, but some processing does
not work like that - for example sorting. For this GNU @strong{parallel} can
put the output of each command into a file. This will sort a big file
in parallel:

@verbatim
  cat bigfile | parallel --pipe --files sort |\
    parallel -Xj1 sort -m {} ';' rm {} >bigfile.sort
@end verbatim

Here @strong{bigfile} is split into blocks of around 1MB, each block ending
in '\n' (which is the default for @strong{--recend}). Each block is passed
to @strong{sort} and the output from @strong{sort} is saved into files. These
files are passed to the second @strong{parallel} that runs @strong{sort -m} on the
files before it removes the files. The output is saved to
@strong{bigfile.sort}.

GNU @strong{parallel}'s @strong{--pipe} maxes out at around 100 MB/s because every
byte has to be copied through GNU @strong{parallel}. But if @strong{bigfile} is a
real (seekable) file GNU @strong{parallel} can by-pass the copying and send
the parts directly to the program:

@verbatim
  parallel --pipepart --block 100m -a bigfile --files sort |\
    parallel -Xj1 sort -m {} ';' rm {} >bigfile.sort
@end verbatim

@node EXAMPLE: Running more than 250 jobs workaround
@chapter EXAMPLE: Running more than 250 jobs workaround

If you need to run a massive amount of jobs in parallel, then you will
likely hit the filehandle limit which is often around 250 jobs. If you
are super user you can raise the limit in /etc/security/limits.conf
but you can also use this workaround. The filehandle limit is per
process. That means that if you just spawn more GNU @strong{parallel}s then
each of them can run 250 jobs. This will spawn up to 2500 jobs:

@verbatim
  cat myinput |\
    parallel --pipe -N 50 --round-robin -j50 parallel -j50 your_prg
@end verbatim

This will spawn up to 62500 jobs (use with caution - you need 64 GB
RAM to do this, and you may need to increase /proc/sys/kernel/pid_max):

@verbatim
  cat myinput |\
    parallel --pipe -N 250 --round-robin -j250 parallel -j250 your_prg
@end verbatim

@node EXAMPLE: Working as mutex and counting semaphore
@chapter EXAMPLE: Working as mutex and counting semaphore

The command @strong{sem} is an alias for @strong{parallel --semaphore}.

A counting semaphore will allow a given number of jobs to be started
in the background.  When the number of jobs are running in the
background, GNU @strong{sem} will wait for one of these to complete before
starting another command. @strong{sem --wait} will wait for all jobs to
complete.

Run 10 jobs concurrently in the background:

@verbatim
  for i in *.log ; do
    echo $i
    sem -j10 gzip $i ";" echo done
  done
  sem --wait
@end verbatim

A mutex is a counting semaphore allowing only one job to run. This
will edit the file @emph{myfile} and prepends the file with lines with the
numbers 1 to 3.

@verbatim
  seq 3 | parallel sem sed -i -e 'i{}' myfile
@end verbatim

As @emph{myfile} can be very big it is important only one process edits
the file at the same time.

Name the semaphore to have multiple different semaphores active at the
same time:

@verbatim
  seq 3 | parallel sem --id mymutex sed -i -e 'i{}' myfile
@end verbatim

@node EXAMPLE: Mutex for a script
@chapter EXAMPLE: Mutex for a script

Assume a script is called from cron or from a web service, but only
one instance can be run at a time. With @strong{sem} and @strong{--shebang-wrap}
the script can be made to wait for other instances to finish. Here in
@strong{bash}:

@verbatim
  #!/usr/bin/sem --shebang-wrap -u --id $0 --fg /bin/bash
  
  echo This will run
  sleep 5
  echo exclusively
@end verbatim

Here @strong{perl}:

@verbatim
  #!/usr/bin/sem --shebang-wrap -u --id $0 --fg /usr/bin/perl
  
  print "This will run ";
  sleep 5;
  print "exclusively\n";
@end verbatim

Here @strong{python}:

@verbatim
  #!/usr/local/bin/sem --shebang-wrap -u --id $0 --fg /usr/bin/python
  
  import time
  print "This will run ";
  time.sleep(5)
  print "exclusively";
@end verbatim

@node EXAMPLE: Start editor with filenames from stdin (standard input)
@chapter EXAMPLE: Start editor with filenames from stdin (standard input)

You can use GNU @strong{parallel} to start interactive programs like emacs or vi:

@verbatim
  cat filelist | parallel --tty -X emacs
  cat filelist | parallel --tty -X vi
@end verbatim

If there are more files than will fit on a single command line, the
editor will be started again with the remaining files.

@node EXAMPLE: Running sudo
@chapter EXAMPLE: Running sudo

@strong{sudo} requires a password to run a command as root. It caches the
access, so you only need to enter the password again if you have not
used @strong{sudo} for a while.

The command:

@verbatim
  parallel sudo echo ::: This is a bad idea
@end verbatim

is no good, as you would be prompted for the sudo password for each of
the jobs. You can either do:

@verbatim
  sudo echo This
  parallel sudo echo ::: is a good idea
@end verbatim

or:

@verbatim
  sudo parallel echo ::: This is a good idea
@end verbatim

This way you only have to enter the sudo password once.

@node EXAMPLE: GNU Parallel as queue system/batch manager
@chapter EXAMPLE: GNU Parallel as queue system/batch manager

GNU @strong{parallel} can work as a simple job queue system or batch manager.
The idea is to put the jobs into a file and have GNU @strong{parallel} read
from that continuously. As GNU @strong{parallel} will stop at end of file we
use @strong{tail} to continue reading:

@verbatim
  true >jobqueue; tail -n+0 -f jobqueue | parallel
@end verbatim

To submit your jobs to the queue:

@verbatim
  echo my_command my_arg >> jobqueue
@end verbatim

You can of course use @strong{-S} to distribute the jobs to remote
computers:

@verbatim
  true >jobqueue; tail -n+0 -f jobqueue | parallel -S ..
@end verbatim

If you keep this running for a long time, jobqueue will grow. A way of
removing the jobs already run is by making GNU @strong{parallel} stop when
it hits a special value and then restart. To use @strong{--eof} to make GNU
@strong{parallel} exit, @strong{tail} also needs to be forced to exit:

@verbatim
  true >jobqueue;
  while true; do
    tail -n+0 -f jobqueue |
      (parallel -E StOpHeRe -S ..; echo GNU Parallel is now done;
       perl -e 'while(<>){/StOpHeRe/ and last};print <>' jobqueue > j2;
       (seq 1000 >> jobqueue &);
       echo Done appending dummy data forcing tail to exit)
    echo tail exited;
    mv j2 jobqueue
  done
@end verbatim

In some cases you can run on more CPUs and computers during the night:

@verbatim
  # Day time
  echo 50% > jobfile
  cp day_server_list ~/.parallel/sshloginfile
  # Night time
  echo 100% > jobfile
  cp night_server_list ~/.parallel/sshloginfile
  tail -n+0 -f jobqueue | parallel --jobs jobfile -S ..
@end verbatim

GNU Parallel discovers if @strong{jobfile} or @strong{~/.parallel/sshloginfile}
changes.

There is a a small issue when using GNU @strong{parallel} as queue
system/batch manager: You have to submit JobSlot number of jobs before
they will start, and after that you can submit one at a time, and job
will start immediately if free slots are available.  Output from the
running or completed jobs are held back and will only be printed when
JobSlots more jobs has been started (unless you use --ungroup or
--line-buffer, in which case the output from the jobs are printed
immediately).  E.g. if you have 10 jobslots then the output from the
first completed job will only be printed when job 11 has started, and
the output of second completed job will only be printed when job 12
has started.

@node EXAMPLE: GNU Parallel as dir processor
@chapter EXAMPLE: GNU Parallel as dir processor

If you have a dir in which users drop files that needs to be processed
you can do this on GNU/Linux (If you know what @strong{inotifywait} is
called on other platforms file a bug report):

@verbatim
  inotifywait -q -m -r -e MOVED_TO -e CLOSE_WRITE --format %w%f my_dir |\
    parallel -u echo
@end verbatim

This will run the command @strong{echo} on each file put into @strong{my_dir} or
subdirs of @strong{my_dir}.

You can of course use @strong{-S} to distribute the jobs to remote
computers:

@verbatim
  inotifywait -q -m -r -e MOVED_TO -e CLOSE_WRITE --format %w%f my_dir |\
    parallel -S ..  -u echo
@end verbatim

If the files to be processed are in a tar file then unpacking one file
and processing it immediately may be faster than first unpacking all
files. Set up the dir processor as above and unpack into the dir.

Using GNU Parallel as dir processor has the same limitations as using
GNU Parallel as queue system/batch manager.

@node QUOTING
@chapter QUOTING

GNU @strong{parallel} is very liberal in quoting. You only need to quote
characters that have special meaning in shell:

@verbatim
  ( ) $ ` ' " < > ; | \
@end verbatim

and depending on context these needs to be quoted, too:

@verbatim
  ~ & # ! ? space * {
@end verbatim

Therefore most people will never need more quoting than putting '\'
in front of the special characters.

Often you can simply put \' around every ':

@verbatim
  perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' file
@end verbatim

can be quoted:

@verbatim
  parallel perl -ne \''/^\S+\s+\S+$/ and print $ARGV,"\n"'\' ::: file
@end verbatim

However, when you want to use a shell variable you need to quote the
$-sign. Here is an example using $PARALLEL_SEQ. This variable is set
by GNU @strong{parallel} itself, so the evaluation of the $ must be done by
the sub shell started by GNU @strong{parallel}:

@verbatim
  seq 10 | parallel -N2 echo seq:\$PARALLEL_SEQ arg1:{1} arg2:{2}
@end verbatim

If the variable is set before GNU @strong{parallel} starts you can do this:

@verbatim
  VAR=this_is_set_before_starting
  echo test | parallel echo {} $VAR
@end verbatim

Prints: @strong{test this_is_set_before_starting}

It is a little more tricky if the variable contains more than one space in a row:

@verbatim
  VAR="two  spaces  between  each  word"
  echo test | parallel echo {} \'"$VAR"\'
@end verbatim

Prints: @strong{test two  spaces  between  each  word}

If the variable should not be evaluated by the shell starting GNU
@strong{parallel} but be evaluated by the sub shell started by GNU
@strong{parallel}, then you need to quote it:

@verbatim
  echo test | parallel VAR=this_is_set_after_starting \; echo {} \$VAR
@end verbatim

Prints: @strong{test this_is_set_after_starting}

It is a little more tricky if the variable contains space:

@verbatim
  echo test |\
    parallel VAR='"two  spaces  between  each  word"' echo {} \'"$VAR"\'
@end verbatim

Prints: @strong{test two  spaces  between  each  word}

$$ is the shell variable containing the process id of the shell. This
will print the process id of the shell running GNU @strong{parallel}:

@verbatim
  seq 10 | parallel echo $$
@end verbatim

And this will print the process ids of the sub shells started by GNU
@strong{parallel}.

@verbatim
  seq 10 | parallel echo \$\$
@end verbatim

If the special characters should not be evaluated by the sub shell
then you need to protect it against evaluation from both the shell
starting GNU @strong{parallel} and the sub shell:

@verbatim
  echo test | parallel echo {} \\\$VAR
@end verbatim

Prints: @strong{test $VAR}

GNU @strong{parallel} can protect against evaluation by the sub shell by
using -q:

@verbatim
  echo test | parallel -q echo {} \$VAR
@end verbatim

Prints: @strong{test $VAR}

This is particularly useful if you have lots of quoting. If you want to run a perl script like this:

@verbatim
  perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' file
@end verbatim

It needs to be quoted like one of these:

@verbatim
  ls | parallel perl -ne '/^\\S+\\s+\\S+\$/\ and\ print\ \$ARGV,\"\\n\"'
  ls | parallel perl -ne \''/^\S+\s+\S+$/ and print $ARGV,"\n"'\'
@end verbatim

Notice how spaces, \'s, "'s, and $'s need to be quoted. GNU @strong{parallel}
can do the quoting by using option -q:

@verbatim
  ls | parallel -q  perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"'
@end verbatim

However, this means you cannot make the sub shell interpret special
characters. For example because of @strong{-q} this WILL NOT WORK:

@verbatim
  ls *.gz | parallel -q "zcat {} >{.}"
  ls *.gz | parallel -q "zcat {} | bzip2 >{.}.bz2"
@end verbatim

because > and | need to be interpreted by the sub shell.

If you get errors like:

@verbatim
  sh: -c: line 0: syntax error near unexpected token
  sh: Syntax error: Unterminated quoted string
  sh: -c: line 0: unexpected EOF while looking for matching `''
  sh: -c: line 1: syntax error: unexpected end of file
@end verbatim

then you might try using @strong{-q}.

If you are using @strong{bash} process substitution like @strong{<(cat foo)} then
you may try @strong{-q} and prepending @emph{command} with @strong{bash -c}:

@verbatim
  ls | parallel -q bash -c 'wc -c <(echo {})'
@end verbatim

Or for substituting output:

@verbatim
  ls | parallel -q bash -c \
    'tar c {} | tee >(gzip >{}.tar.gz) | bzip2 >{}.tar.bz2'
@end verbatim

@strong{Conclusion}: To avoid dealing with the quoting problems it may be
easier just to write a small script or a function (remember to
@strong{export -f} the function) and have GNU @strong{parallel} call that.

@node LIST RUNNING JOBS
@chapter LIST RUNNING JOBS

If you want a list of the jobs currently running you can run:

@verbatim
  killall -USR1 parallel
@end verbatim

GNU @strong{parallel} will then print the currently running jobs on stderr
(standard error).

@node COMPLETE RUNNING JOBS BUT DO NOT START NEW JOBS
@chapter COMPLETE RUNNING JOBS BUT DO NOT START NEW JOBS

If you regret starting a lot of jobs you can simply break GNU @strong{parallel},
but if you want to make sure you do not have half-completed jobs you
should send the signal @strong{SIGTERM} to GNU @strong{parallel}:

@verbatim
  killall -TERM parallel
@end verbatim

This will tell GNU @strong{parallel} to not start any new jobs, but wait until
the currently running jobs are finished before exiting.

@node ENVIRONMENT VARIABLES
@chapter ENVIRONMENT VARIABLES

@table @asis
@item $PARALLEL_PID
@anchor{$PARALLEL_PID}

The environment variable $PARALLEL_PID is set by GNU @strong{parallel} and
is visible to the jobs started from GNU @strong{parallel}. This makes it
possible for the jobs to communicate directly to GNU @strong{parallel}.
Remember to quote the $, so it gets evaluated by the correct
shell.

@strong{Example:} If each of the jobs tests a solution and one of jobs finds
the solution the job can tell GNU @strong{parallel} not to start more jobs
by: @strong{kill -TERM $PARALLEL_PID}. This only works on the local
computer.

@item $PARALLEL_SHELL
@anchor{$PARALLEL_SHELL}

Use this shell the shell for the commands run by GNU Parallel:

@itemize
@item $PARALLEL_SHELL. If undefined use:

@item The shell that started GNU Parallel. If that cannot be determined:

@item $SHELL. If undefined use:

@item /bin/sh

@end itemize

@item $PARALLEL_SSH
@anchor{$PARALLEL_SSH}

GNU @strong{parallel} defaults to using @strong{ssh} for remote access. This can
be overridden with $PARALLEL_SSH, which again can be overridden with
@strong{--ssh}. It can also be set on a per server basis (see
@strong{--sshlogin}).

@item $PARALLEL_SEQ
@anchor{$PARALLEL_SEQ}

$PARALLEL_SEQ will be set to the sequence number of the job
running. Remember to quote the $, so it gets evaluated by the correct
shell.

@strong{Example:}

@verbatim
  seq 10 | parallel -N2 \
    echo seq:'$'PARALLEL_SEQ arg1:{1} arg2:{2}
@end verbatim

@item $PARALLEL_TMUX
@anchor{$PARALLEL_TMUX}

Path to @strong{tmux}. If unset the @strong{tmux} in $PATH is used.

@item $TMPDIR
@anchor{$TMPDIR}

Directory for temporary files. See: @strong{--tmpdir}.

@item $PARALLEL
@anchor{$PARALLEL}

The environment variable $PARALLEL will be used as default options for
GNU @strong{parallel}. If the variable contains special shell characters
(e.g. $, *, or space) then these need to be to be escaped with \.

@strong{Example:}

@verbatim
  cat list | parallel -j1 -k -v ls
  cat list | parallel -j1 -k -v -S"myssh user@server" ls
@end verbatim

can be written as:

@verbatim
  cat list | PARALLEL="-kvj1" parallel ls
  cat list | PARALLEL='-kvj1 -S myssh\ user@server' \
    parallel echo
@end verbatim

Notice the \ in the middle is needed because 'myssh' and 'user@@server'
must be one argument.

@end table

@node DEFAULT PROFILE (CONFIG FILE)
@chapter DEFAULT PROFILE (CONFIG FILE)

The global configuration file /etc/parallel/config, followed by user
configuration file ~/.parallel/config (formerly known as .parallelrc)
will be read in turn if they exist.  Lines starting with '#' will be
ignored. The format can follow that of the environment variable
$PARALLEL, but it is often easier to simply put each option on its own
line.

Options on the command line take precedence, followed by the
environment variable $PARALLEL, user configuration file
~/.parallel/config, and finally the global configuration file
/etc/parallel/config.

Note that no file that is read for options, nor the environment
variable $PARALLEL, may contain retired options such as @strong{--tollef}.

@node PROFILE FILES
@chapter PROFILE FILES

If @strong{--profile} set, GNU @strong{parallel} will read the profile from that
file rather than the global or user configuration files. You can have
multiple @strong{--profiles}.

Example: Profile for running a command on every sshlogin in
~/.ssh/sshlogins and prepend the output with the sshlogin:

@verbatim
  echo --tag -S .. --nonall > ~/.parallel/n
  parallel -Jn uptime
@end verbatim

Example: Profile for running every command with @strong{-j-1} and @strong{nice}

@verbatim
  echo -j-1 nice > ~/.parallel/nice_profile
  parallel -J nice_profile bzip2 -9 ::: *
@end verbatim

Example: Profile for running a perl script before every command:

@verbatim
  echo "perl -e '\$a=\$\$; print \$a,\" \",'\$PARALLEL_SEQ',\" \";';" \
    > ~/.parallel/pre_perl
  parallel -J pre_perl echo ::: *
@end verbatim

Note how the $ and " need to be quoted using \.

Example: Profile for running distributed jobs with @strong{nice} on the
remote computers:

@verbatim
  echo -S .. nice > ~/.parallel/dist
  parallel -J dist --trc {.}.bz2 bzip2 -9 ::: *
@end verbatim

@node EXIT STATUS
@chapter EXIT STATUS

Exit status depends on @strong{--halt-on-error} if one of these are used:
success=X, success=Y%, fail=Y%.

@table @asis
@item 0
@anchor{0 1}

All jobs ran without error. If success=X is used: X jobs ran without
error. If success=Y% is used: Y% of the jobs ran without error.

@item 1-100
@anchor{1-100}

Some of the jobs failed. The exit status gives the number of failed
jobs. If Y% is used the exit status is the percentage of jobs that
failed.

@item 101
@anchor{101}

More than 100 jobs failed.

@item 255
@anchor{255}

Other error.

@item -1 (In joblog and SQL table)
@anchor{-1 (In joblog and SQL table)}

Killed by Ctrl-C, timeout, not enough memory or similar.

@item -2 (In joblog and SQL table)
@anchor{-2 (In joblog and SQL table)}

$job->skip() was called in @strong{@{= =@}}.

@item -1000 (In SQL table)
@anchor{-1000 (In SQL table)}

Job is ready to run (set by --sqlmaster).

@item -1220 (In SQL table)
@anchor{-1220 (In SQL table)}

Job is taken by worker (set by --sqlworker).

@end table

If fail=1 is used, the exit status will be the exit status of the
failing job.

@node DIFFERENCES BETWEEN GNU Parallel AND ALTERNATIVES
@chapter DIFFERENCES BETWEEN GNU Parallel AND ALTERNATIVES

There are a lot programs with some of the functionality of GNU
@strong{parallel}. GNU @strong{parallel} strives to include the best of the
functionality without sacrificing ease of use.

@menu
* SUMMARY TABLE::
* DIFFERENCES BETWEEN xargs AND GNU Parallel::
* DIFFERENCES BETWEEN find -exec AND GNU Parallel::
* DIFFERENCES BETWEEN make -j AND GNU Parallel::
* DIFFERENCES BETWEEN ppss AND GNU Parallel::
* DIFFERENCES BETWEEN pexec AND GNU Parallel::
* DIFFERENCES BETWEEN xjobs AND GNU Parallel::
* DIFFERENCES BETWEEN prll AND GNU Parallel::
* DIFFERENCES BETWEEN dxargs AND GNU Parallel::
* DIFFERENCES BETWEEN mdm/middleman AND GNU Parallel::
* DIFFERENCES BETWEEN xapply AND GNU Parallel::
* DIFFERENCES BETWEEN AIX apply AND GNU Parallel::
* DIFFERENCES BETWEEN paexec AND GNU Parallel::
* DIFFERENCES BETWEEN map AND GNU Parallel::
* DIFFERENCES BETWEEN ladon AND GNU Parallel::
* DIFFERENCES BETWEEN jobflow AND GNU Parallel::
* DIFFERENCES BETWEEN gargs AND GNU Parallel::
* DIFFERENCES BETWEEN orgalorg AND GNU Parallel::
* DIFFERENCES BETWEEN Rust parallel AND GNU Parallel::
* DIFFERENCES BETWEEN ClusterSSH AND GNU Parallel::
@end menu

@node SUMMARY TABLE
@section SUMMARY TABLE

The following features are in some of the comparable tools:

Inputs
 I1. Arguments can be read from stdin
 I2. Arguments can be read from a file
 I3. Arguments can be read from multiple files
 I4. Arguments can be read from command line
 I5. Arguments can be read from a table
 I6. Arguments can be read from the same file using #! (shebang)
 I7. Line oriented input as default (Quoting of special chars not needed)

Manipulation of input
 M1. Composed command
 M2. Multiple arguments can fill up an execution line
 M3. Arguments can be put anywhere in the execution line
 M4. Multiple arguments can be put anywhere in the execution line
 M5. Arguments can be replaced with context
 M6. Input can be treated as the complete command line

Outputs
 O1. Grouping output so output from different jobs do not mix
 O2. Send stderr (standard error) to stderr (standard error)
 O3. Send stdout (standard output) to stdout (standard output)
 O4. Order of output can be same as order of input
 O5. Stdout only contains stdout (standard output) from the command
 O6. Stderr only contains stderr (standard error) from the command

Execution
 E1. Running jobs in parallel
 E2. List running jobs
 E3. Finish running jobs, but do not start new jobs
 E4. Number of running jobs can depend on number of cpus
 E5. Finish running jobs, but do not start new jobs after first failure
 E6. Number of running jobs can be adjusted while running

Remote execution
 R1. Jobs can be run on remote computers
 R2. Basefiles can be transferred
 R3. Argument files can be transferred
 R4. Result files can be transferred
 R5. Cleanup of transferred files
 R6. No config files needed
 R7. Do not run more than SSHD's MaxStartups can handle
 R8. Configurable SSH command
 R9. Retry if connection breaks occasionally

Semaphore
 S1. Possibility to work as a mutex
 S2. Possibility to work as a counting semaphore

Legend
 - = no
 x = not applicable
 ID = yes

As every new version of the programs are not tested the table may be
outdated. Please file a bug-report if you find errors (See REPORTING
BUGS).

parallel:
I1 I2 I3 I4 I5 I6 I7
M1 M2 M3 M4 M5 M6
O1 O2 O3 O4 O5 O6
E1 E2 E3 E4 E5 E6
R1 R2 R3 R4 R5 R6 R7 R8 R9
S1 S2

xargs:
I1 I2 -  -  -  -  -
-  M2 M3 -  -  -
-  O2 O3 -  O5 O6
E1 -  -  -  -  -
-  -  -  -  -  x  -  -  -
-  -

find -exec:
-  -  -  x  -  x  -
-  M2 M3 -  -  -  -
-  O2 O3 O4 O5 O6
-  -  -  -  -  -  -
-  -  -  -  -  -  -  -  -
x  x

make -j:
-  -  -  -  -  -  -
-  -  -  -  -  -
O1 O2 O3 -  x  O6
E1 -  -  -  E5 -
-  -  -  -  -  -  -  -  -
-  -

ppss:
I1 I2 -  -  -  -  I7
M1 -  M3 -  -  M6
O1 -  -  x  -  -
E1 E2 ?E3 E4 - -
R1 R2 R3 R4 -  -  ?R7 ? ?
-  -

pexec:
I1 I2 -  I4 I5 -  -
M1 -  M3 -  -  M6
O1 O2 O3 -  O5 O6
E1 -  -  E4 -  E6
R1 -  -  -  -  R6 -  -  -
S1 -

xjobs, prll, dxargs, mdm/middelman, xapply, paexec, ladon, jobflow,
ClusterSSH: TODO - Please file a bug-report if you know what features
they support (See REPORTING BUGS).

@node DIFFERENCES BETWEEN xargs AND GNU Parallel
@section DIFFERENCES BETWEEN xargs AND GNU Parallel

@strong{xargs} offers some of the same possibilities as GNU @strong{parallel}.

@strong{xargs} deals badly with special characters (such as space, \, ' and
"). To see the problem try this:

@verbatim
  touch important_file
  touch 'not important_file'
  ls not* | xargs rm
  mkdir -p "My brother's 12\" records"
  ls | xargs rmdir
  touch 'c:\windows\system32\clfs.sys'
  echo 'c:\windows\system32\clfs.sys' | xargs ls -l
@end verbatim

You can specify @strong{-0}, but many input generators are not
optimized for using @strong{NUL} as separator but are optimized for
@strong{newline} as separator. E.g @strong{head}, @strong{tail}, @strong{awk}, @strong{ls}, @strong{echo},
@strong{sed}, @strong{tar -v}, @strong{perl} (@strong{-0} and \0 instead of \n), @strong{locate}
(requires using @strong{-0}), @strong{find} (requires using @strong{-print0}), @strong{grep}
(requires user to use @strong{-z} or @strong{-Z}), @strong{sort} (requires using @strong{-z}).

GNU @strong{parallel}'s newline separation can be emulated with:

@strong{cat | xargs -d "\n" -n1 @emph{command}}

@strong{xargs} can run a given number of jobs in parallel, but has no
support for running number-of-cpu-cores jobs in parallel.

@strong{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. The example
@strong{Parallel grep} cannot be done reliably with @strong{xargs} because of
this. To see this in action try:

@verbatim
  parallel perl -e '\$a=\"1{}\"x10000000\;print\ \$a,\"\\n\"' '>' {} \
    ::: a b c d e f
  ls -l a b c d e f
  parallel -kP4 -n1 grep 1 > out.par ::: a b c d e f
  echo a b c d e f | xargs -P4 -n1 grep 1 > out.xargs-unbuf
  echo a b c d e f | \
    xargs -P4 -n1 grep --line-buffered 1 > out.xargs-linebuf
  echo a b c d e f | xargs -n1 grep 1 > out.xargs-serial
  ls -l out*
  md5sum out*
@end verbatim

@strong{xargs} has no support for keeping the order of the output, therefore
if running jobs in parallel using @strong{xargs} the output of the second
job cannot be postponed till the first job is done.

@strong{xargs} has no support for running jobs on remote computers.

@strong{xargs} has no support for context replace, so you will have to create the
arguments.

If you use a replace string in @strong{xargs} (@strong{-I}) you can not force
@strong{xargs} to use more than one argument.

Quoting in @strong{xargs} works like @strong{-q} in GNU @strong{parallel}. This means
composed commands and redirection require using @strong{bash -c}.

@verbatim
  ls | parallel "wc {} >{}.wc"
  ls | parallel "echo {}; ls {}|wc"
@end verbatim

becomes (assuming you have 8 cores)

@verbatim
  ls | xargs -d "\n" -P8 -I {} bash -c "wc {} >{}.wc"
  ls | xargs -d "\n" -P8 -I {} bash -c "echo {}; ls {}|wc"
@end verbatim

@node DIFFERENCES BETWEEN find -exec AND GNU Parallel
@section DIFFERENCES BETWEEN find -exec AND GNU Parallel

@strong{find -exec} offer some of the same possibilities as GNU @strong{parallel}.

@strong{find -exec} only works on files. So processing other input (such as
hosts or URLs) will require creating these inputs as files. @strong{find
-exec} has no support for running commands in parallel.

@node DIFFERENCES BETWEEN make -j AND GNU Parallel
@section DIFFERENCES BETWEEN make -j AND GNU Parallel

@strong{make -j} can run jobs in parallel, but requires a crafted Makefile
to do this. That results in extra quoting to get filename containing
newline to work correctly.

@strong{make -j} computes a dependency graph before running jobs. Jobs run
by GNU @strong{parallel} does not depend on eachother.

(Very early versions of GNU @strong{parallel} were coincidently implemented
using @strong{make -j}).

@node DIFFERENCES BETWEEN ppss AND GNU Parallel
@section DIFFERENCES BETWEEN ppss AND GNU Parallel

@strong{ppss} is also a tool for running jobs in parallel.

The output of @strong{ppss} is status information and thus not useful for
using as input for another command. The output from the jobs are put
into files.

The argument replace string ($ITEM) cannot be changed. Arguments must
be quoted - thus arguments containing special characters (space '"&!*)
may cause problems. More than one argument is not supported. File
names containing newlines are not processed correctly. When reading
input from a file null cannot be used as a terminator. @strong{ppss} needs
to read the whole input file before starting any jobs.

Output and status information is stored in ppss_dir and thus requires
cleanup when completed. If the dir is not removed before running
@strong{ppss} again it may cause nothing to happen as @strong{ppss} thinks the
task is already done. GNU @strong{parallel} will normally not need cleaning
up if running locally and will only need cleaning up if stopped
abnormally and running remote (@strong{--cleanup} may not complete if
stopped abnormally). The example @strong{Parallel grep} would require extra
postprocessing if written using @strong{ppss}.

For remote systems PPSS requires 3 steps: config, deploy, and
start. GNU @strong{parallel} only requires one step.

@menu
* EXAMPLES FROM ppss MANUAL::
@end menu

@node EXAMPLES FROM ppss MANUAL
@subsection EXAMPLES FROM ppss MANUAL

Here are the examples from @strong{ppss}'s manual page with the equivalent
using GNU @strong{parallel}:

@strong{1} ./ppss.sh standalone -d /path/to/files -c 'gzip '

@strong{1} find /path/to/files -type f | parallel gzip

@strong{2} ./ppss.sh standalone -d /path/to/files -c 'cp "$ITEM" /destination/dir '

@strong{2} find /path/to/files -type f | parallel cp @{@} /destination/dir

@strong{3} ./ppss.sh standalone -f list-of-urls.txt -c 'wget -q '

@strong{3} parallel -a list-of-urls.txt wget -q

@strong{4} ./ppss.sh standalone -f list-of-urls.txt -c 'wget -q "$ITEM"'

@strong{4} parallel -a list-of-urls.txt wget -q @{@}

@strong{5} ./ppss config -C config.cfg -c 'encode.sh ' -d /source/dir -m
192.168.1.100 -u ppss -k ppss-key.key -S ./encode.sh -n nodes.txt -o
/some/output/dir --upload --download ; ./ppss deploy -C config.cfg ;
./ppss start -C config

@strong{5} # parallel does not use configs. If you want a different username put it in nodes.txt: user@@hostname

@strong{5} find source/dir -type f | parallel --sshloginfile nodes.txt --trc @{.@}.mp3 lame -a @{@} -o @{.@}.mp3 --preset standard --quiet

@strong{6} ./ppss stop -C config.cfg

@strong{6} killall -TERM parallel

@strong{7} ./ppss pause -C config.cfg

@strong{7} Press: CTRL-Z or killall -SIGTSTP parallel

@strong{8} ./ppss continue -C config.cfg

@strong{8} Enter: fg or killall -SIGCONT parallel

@strong{9} ./ppss.sh status -C config.cfg

@strong{9} killall -SIGUSR2 parallel

@node DIFFERENCES BETWEEN pexec AND GNU Parallel
@section DIFFERENCES BETWEEN pexec AND GNU Parallel

@strong{pexec} is also a tool for running jobs in parallel.

@menu
* EXAMPLES FROM pexec MANUAL::
@end menu

@node EXAMPLES FROM pexec MANUAL
@subsection EXAMPLES FROM pexec MANUAL

Here are the examples from @strong{pexec}'s info page with the equivalent
using GNU @strong{parallel}:

@strong{1} pexec -o sqrt-%s.dat -p "$(seq 10)" -e NUM -n 4 -c -- \
  'echo "scale=10000;sqrt($NUM)" | bc'

@strong{1} seq 10 | parallel -j4 'echo "scale=10000;sqrt(@{@})" | bc > sqrt-@{@}.dat'

@strong{2} pexec -p "$(ls myfiles*.ext)" -i %s -o %s.sort -- sort

@strong{2} ls myfiles*.ext | parallel sort @{@} ">@{@}.sort"

@strong{3} pexec -f image.list -n auto -e B -u star.log -c -- \
  'fistar $B.fits -f 100 -F id,x,y,flux -o $B.star'

@strong{3} parallel -a image.list \
  'fistar @{@}.fits -f 100 -F id,x,y,flux -o @{@}.star' 2>star.log

@strong{4} pexec -r *.png -e IMG -c -o - -- \
  'convert $IMG $@{IMG%.png@}.jpeg ; "echo $IMG: done"'

@strong{4} ls *.png | parallel 'convert @{@} @{.@}.jpeg; echo @{@}: done'

@strong{5} pexec -r *.png -i %s -o %s.jpg -c 'pngtopnm | pnmtojpeg'

@strong{5} ls *.png | parallel 'pngtopnm < @{@} | pnmtojpeg > @{@}.jpg'

@strong{6} for p in *.png ; do echo $@{p%.png@} ; done | \
  pexec -f - -i %s.png -o %s.jpg -c 'pngtopnm | pnmtojpeg'

@strong{6} ls *.png | parallel 'pngtopnm < @{@} | pnmtojpeg > @{.@}.jpg'

@strong{7} LIST=$(for p in *.png ; do echo $@{p%.png@} ; done)
  pexec -r $LIST -i %s.png -o %s.jpg -c 'pngtopnm | pnmtojpeg'

@strong{7} ls *.png | parallel 'pngtopnm < @{@} | pnmtojpeg > @{.@}.jpg'

@strong{8} pexec -n 8 -r *.jpg -y unix -e IMG -c \
  'pexec -j -m blockread -d $IMG | \
  jpegtopnm | pnmscale 0.5 | pnmtojpeg | \
  pexec -j -m blockwrite -s th_$IMG'

@strong{8} Combining GNU @strong{parallel} and GNU @strong{sem}.

@strong{8} ls *jpg | parallel -j8 'sem --id blockread cat @{@} | jpegtopnm |' \
  'pnmscale 0.5 | pnmtojpeg | sem --id blockwrite cat > th_@{@}'

@strong{8} If reading and writing is done to the same disk, this may be
faster as only one process will be either reading or writing:

@strong{8} ls *jpg | parallel -j8 'sem --id diskio cat @{@} | jpegtopnm |' \
  'pnmscale 0.5 | pnmtojpeg | sem --id diskio cat > th_@{@}'

@node DIFFERENCES BETWEEN xjobs AND GNU Parallel
@section DIFFERENCES BETWEEN xjobs AND GNU Parallel

@strong{xjobs} is also a tool for running jobs in parallel. It only supports
running jobs on your local computer.

@strong{xjobs} deals badly with special characters just like @strong{xargs}. See
the section @strong{DIFFERENCES BETWEEN xargs AND GNU Parallel}.

Here are the examples from @strong{xjobs}'s man page with the equivalent
using GNU @strong{parallel}:

@strong{1} ls -1 *.zip | xjobs unzip

@strong{1} ls *.zip | parallel unzip

@strong{2} ls -1 *.zip | xjobs -n unzip

@strong{2} ls *.zip | parallel unzip >/dev/null

@strong{3} find . -name '*.bak' | xjobs gzip

@strong{3} find . -name '*.bak' | parallel gzip

@strong{4} ls -1 *.jar | sed 's/\(.*\)/\1 > \1.idx/' | xjobs jar tf

@strong{4} ls *.jar | parallel jar tf @{@} '>' @{@}.idx

@strong{5} xjobs -s script

@strong{5} cat script | parallel

@strong{6} mkfifo /var/run/my_named_pipe;
xjobs -s /var/run/my_named_pipe &
echo unzip 1.zip >> /var/run/my_named_pipe;
echo tar cf /backup/myhome.tar /home/me >> /var/run/my_named_pipe

@strong{6} mkfifo /var/run/my_named_pipe;
cat /var/run/my_named_pipe | parallel &
echo unzip 1.zip >> /var/run/my_named_pipe;
echo tar cf /backup/myhome.tar /home/me >> /var/run/my_named_pipe

@node DIFFERENCES BETWEEN prll AND GNU Parallel
@section DIFFERENCES BETWEEN prll AND GNU Parallel

@strong{prll} is also a tool for running jobs in parallel. It does not
support running jobs on remote computers.

@strong{prll} encourages using BASH aliases and BASH functions instead of
scripts. GNU @strong{parallel} supports scripts directly, functions if they
are exported using @strong{export -f}, and aliases if using @strong{env_parallel}.

@strong{prll} generates a lot of status information on stderr (standard
error) which makes it harder to use the stderr (standard error) output
of the job directly as input for another program.

Here is the example from @strong{prll}'s man page with the equivalent
using GNU @strong{parallel}:

@verbatim
  prll -s 'mogrify -flip $1' *.jpg
  parallel mogrify -flip ::: *.jpg
@end verbatim

@node DIFFERENCES BETWEEN dxargs AND GNU Parallel
@section DIFFERENCES BETWEEN dxargs AND GNU Parallel

@strong{dxargs} is also a tool for running jobs in parallel.

@strong{dxargs} does not deal well with more simultaneous jobs than SSHD's
MaxStartups. @strong{dxargs} is only built for remote run jobs, but does not
support transferring of files.

@node DIFFERENCES BETWEEN mdm/middleman AND GNU Parallel
@section DIFFERENCES BETWEEN mdm/middleman AND GNU Parallel

middleman(mdm) is also a tool for running jobs in parallel.

Here are the shellscripts of http://mdm.berlios.de/usage.html ported
to GNU @strong{parallel}:

@verbatim
  seq 19 | parallel buffon -o - | sort -n > result
  cat files | parallel cmd
  find dir -execdir sem cmd {} \;
@end verbatim

@node DIFFERENCES BETWEEN xapply AND GNU Parallel
@section DIFFERENCES BETWEEN xapply AND GNU Parallel

@strong{xapply} can run jobs in parallel on the local computer.

Here are the examples from @strong{xapply}'s man page with the equivalent
using GNU @strong{parallel}:

@strong{1} xapply '(cd %1 && make all)' */

@strong{1} parallel 'cd @{@} && make all' ::: */

@strong{2} xapply -f 'diff %1 ../version5/%1' manifest | more

@strong{2} parallel diff @{@} ../version5/@{@} < manifest | more

@strong{3} xapply -p/dev/null -f 'diff %1 %2' manifest1 checklist1

@strong{3} parallel --link diff @{1@} @{2@} :::: manifest1 checklist1

@strong{4} xapply 'indent' *.c

@strong{4} parallel indent ::: *.c

@strong{5} find ~ksb/bin -type f ! -perm -111 -print | xapply -f -v 'chmod a+x' -

@strong{5} find ~ksb/bin -type f ! -perm -111 -print | parallel -v chmod a+x

@strong{6} find */ -... | fmt 960 1024 | xapply -f -i /dev/tty 'vi' -

@strong{6} sh <(find */ -... | parallel -s 1024 echo vi)

@strong{6} find */ -... | parallel -s 1024 -Xuj1 vi

@strong{7} find ... | xapply -f -5 -i /dev/tty 'vi' - - - - -

@strong{7} sh <(find ... |parallel -n5 echo vi)

@strong{7} find ... |parallel -n5 -uj1 vi

@strong{8} xapply -fn "" /etc/passwd

@strong{8} parallel -k echo < /etc/passwd

@strong{9} tr ':' '\012' < /etc/passwd | xapply -7 -nf 'chown %1 %6' - - - - - - -

@strong{9} tr ':' '\012' < /etc/passwd | parallel -N7 chown @{1@} @{6@}

@strong{10} xapply '[ -d %1/RCS ] || echo %1' */

@strong{10} parallel '[ -d @{@}/RCS ] || echo @{@}' ::: */

@strong{11} xapply -f '[ -f %1 ] && echo %1' List | ...

@strong{11} parallel '[ -f @{@} ] && echo @{@}' < List | ...

@node DIFFERENCES BETWEEN AIX apply AND GNU Parallel
@section DIFFERENCES BETWEEN AIX apply AND GNU Parallel

@strong{apply} can build command lines based on a template and arguments -
very much like GNU @strong{parallel}. @strong{apply} does not run jobs in
parallel. @strong{apply} does not use an argument separator (like @strong{:::});
instead the template must be the first argument.

Here are the examples from
https://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.cmds1/apply.htm

1. To obtain results similar to those of the @strong{ls} command, enter:

@verbatim
  apply echo *
  parallel echo ::: *
@end verbatim

2. To compare the file named @strong{a1} to the file named @strong{b1}, and the
file named @strong{a2} to the file named @strong{b2}, enter:

@verbatim
  apply -2 cmp a1 b1 a2 b2
  parallel -N2 cmp ::: a1 b1 a2 b2
@end verbatim

3. To run the @strong{who} command five times, enter:

@verbatim
  apply -0 who 1 2 3 4 5
  parallel -N0 who ::: 1 2 3 4 5
@end verbatim

4. To link all files in the current directory to the directory
@strong{/usr/joe}, enter:

@verbatim
  apply 'ln %1 /usr/joe' *
  parallel ln {} /usr/joe ::: *
@end verbatim

@node DIFFERENCES BETWEEN paexec AND GNU Parallel
@section DIFFERENCES BETWEEN paexec AND GNU Parallel

@strong{paexec} can run jobs in parallel on both the local and remote computers.

@strong{paexec} requires commands to print a blank line as the last
output. This means you will have to write a wrapper for most programs.

@strong{paexec} has a job dependency facility so a job can depend on another
job to be executed successfully. Sort of a poor-man's @strong{make}.

Here are the examples from @strong{paexec}'s example catalog with the equivalent
using GNU @strong{parallel}:

@table @asis
@item 1_div_X_run:
@anchor{1_div_X_run:}

@verbatim
  ../../paexec -s -l -c "`pwd`/1_div_X_cmd" -n +1 <<EOF [...]
  parallel echo {} '|' `pwd`/1_div_X_cmd <<EOF [...]
@end verbatim

@item all_substr_run:
@anchor{all_substr_run:}

@verbatim
  ../../paexec -lp -c "`pwd`/all_substr_cmd" -n +3 <<EOF [...]
  parallel echo {} '|' `pwd`/all_substr_cmd <<EOF [...]
@end verbatim

@item cc_wrapper_run:
@anchor{cc_wrapper_run:}

@verbatim
  ../../paexec -c "env CC=gcc CFLAGS=-O2 `pwd`/cc_wrapper_cmd" \
             -n 'host1 host2' \
             -t '/usr/bin/ssh -x' <<EOF [...]
  parallel echo {} '|' "env CC=gcc CFLAGS=-O2 `pwd`/cc_wrapper_cmd" \
             -S host1,host2 <<EOF [...]
  # This is not exactly the same, but avoids the wrapper
  parallel gcc -O2 -c -o {.}.o {} \
             -S host1,host2 <<EOF [...]
@end verbatim

@item toupper_run:
@anchor{toupper_run:}

@verbatim
  ../../paexec -lp -c "`pwd`/toupper_cmd" -n +10 <<EOF [...]
  parallel echo {} '|' ./toupper_cmd <<EOF [...]
  # Without the wrapper:
  parallel echo {} '| awk {print\ toupper\(\$0\)}' <<EOF [...]
@end verbatim

@end table

@node DIFFERENCES BETWEEN map AND GNU Parallel
@section DIFFERENCES BETWEEN map AND GNU Parallel

@strong{map} sees it as a feature to have less features and in doing so it
also handles corner cases incorrectly. A lot of GNU @strong{parallel}'s code
is to handle corner cases correctly on every platform, so you will not
get a nasty surprise if a user for example saves a file called: @emph{My
brother's 12" records.txt}

@strong{map}'s example showing how to deal with special characters fails on
special characters:

@verbatim
  echo "The Cure" > My\ brother\'s\ 12\"\ records

  ls | \
    map 'echo -n `gzip < "%" | wc -c`; echo -n '*100/'; wc -c < "%"' | bc
@end verbatim

It works with GNU @strong{parallel}:

@verbatim
  ls | \
    parallel 'echo -n `gzip < {} | wc -c`; echo -n '*100/'; wc -c < {}' | bc
@end verbatim

And you can even get the file name prepended:

@verbatim
  ls | \
    parallel --tag '(echo -n `gzip < {} | wc -c`'*100/'; wc -c < {}) | bc'
@end verbatim

@strong{map} has no support for grouping. So this gives the wrong results
without any warnings:

@verbatim
  parallel perl -e '\$a=\"1{}\"x10000000\;print\ \$a,\"\\n\"' '>' {} \
    ::: a b c d e f
  ls -l a b c d e f
  parallel -kP4 -n1 grep 1 > out.par ::: a b c d e f
  map -p 4 'grep 1' a b c d e f > out.map-unbuf
  map -p 4 'grep --line-buffered 1' a b c d e f > out.map-linebuf
  map -p 1 'grep --line-buffered 1' a b c d e f > out.map-serial
  ls -l out*
  md5sum out*
@end verbatim

The documentation shows a workaround, but not only does that mix
stdout (standard output) with stderr (standard error) it also fails
completely for certain jobs (and may even be considered less readable):

@verbatim
  parallel echo -n {} ::: 1 2 3

  map -p 4 'echo -n % 2>&1 | sed -e "s/^/$$:/"' 1 2 3 | sort | cut -f2- -d:
@end verbatim

@strong{map}s replacement strings (% %D %B %E) can be simulated in GNU
@strong{parallel} by putting this in @strong{~/.parallel/config}:

@verbatim
  --rpl '%'
  --rpl '%D $_=::shell_quote(::dirname($_));'
  --rpl '%B s:.*/::;s:\.[^/.]+$::;'
  --rpl '%E s:.*\.::'
@end verbatim

@strong{map} cannot handle bundled options: @strong{map -vp 0 echo this fails}

@strong{map} does not have an argument separator on the command line, but
uses the first argument as command. This makes quoting harder which again
may affect readability. Compare:

@verbatim
  map -p 2 perl\\\ -ne\\\ \\\'/^\\\\S+\\\\s+\\\\S+\\\$/\\\ and\\\ print\\\ \\\$ARGV,\\\"\\\\n\\\"\\\' *

  parallel -q perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' ::: *
@end verbatim

@strong{map} can do multiple arguments with context replace, but not without
context replace:

@verbatim
  parallel --xargs echo 'BEGIN{'{}'}END' ::: 1 2 3
@end verbatim

@strong{map} does not set exit value according to whether one of the jobs
failed:

@verbatim
  parallel false ::: 1 || echo Job failed

  map false 1 || echo Never run
@end verbatim

@strong{map} requires Perl v5.10.0 making it harder to use on old systems.

@strong{map} has no way of using % in the command (GNU Parallel has -I to
specify another replacement string than @strong{@{@}}).

By design @strong{map} is option incompatible with @strong{xargs}, it does not
have remote job execution, a structured way of saving results,
multiple input sources, progress indicator, configurable record
delimiter (only field delimiter), logging of jobs run with possibility
to resume, keeping the output in the same order as input, --pipe
processing, and dynamically timeouts.

@node DIFFERENCES BETWEEN ladon AND GNU Parallel
@section DIFFERENCES BETWEEN ladon AND GNU Parallel

@strong{ladon} can run multiple jobs on files in parallel.

@strong{ladon} only works on files and the only way to specify files is
using a quoted glob string (such as \*.jpg). It is not possible to
list the files manually.

As replacement strings it uses FULLPATH DIRNAME BASENAME EXT RELDIR RELPATH

These can be simulated using GNU @strong{parallel} by putting this in @strong{~/.parallel/config}:

@verbatim
    --rpl 'FULLPATH $_=::shell_quote($_);chomp($_=qx{readlink -f $_});'
    --rpl 'DIRNAME $_=::shell_quote(::dirname($_));chomp($_=qx{readlink -f $_});'
    --rpl 'BASENAME s:.*/::;s:\.[^/.]+$::;'
    --rpl 'EXT s:.*\.::'
    --rpl 'RELDIR $_=::shell_quote($_);chomp(($_,$c)=qx{readlink -f $_;pwd});s:\Q$c/\E::;$_=::dirname($_);'
    --rpl 'RELPATH $_=::shell_quote($_);chomp(($_,$c)=qx{readlink -f $_;pwd});s:\Q$c/\E::;'
@end verbatim

@strong{ladon} deals badly with filenames containing " and newline, and it fails for output larger than 200k:

@verbatim
    ladon '*' -- seq 36000 | wc
@end verbatim

@menu
* EXAMPLES FROM ladon MANUAL::
@end menu

@node EXAMPLES FROM ladon MANUAL
@subsection EXAMPLES FROM ladon MANUAL

It is assumed that the '--rpl's above are put in @strong{~/.parallel/config}
and that it is run under a shell that supports '**' globbing (such as @strong{zsh}):

@strong{1} ladon "**/*.txt" -- echo RELPATH

@strong{1} parallel echo RELPATH ::: **/*.txt

@strong{2} ladon "~/Documents/**/*.pdf" -- shasum FULLPATH >hashes.txt

@strong{2} parallel shasum FULLPATH ::: ~/Documents/**/*.pdf >hashes.txt

@strong{3} ladon -m thumbs/RELDIR "**/*.jpg" -- convert FULLPATH -thumbnail 100x100^ -gravity center -extent 100x100 thumbs/RELPATH

@strong{3} parallel mkdir -p thumbs/RELDIR\; convert FULLPATH -thumbnail 100x100^ -gravity center -extent 100x100 thumbs/RELPATH ::: **/*.jpg

@strong{4} ladon "~/Music/*.wav" -- lame -V 2 FULLPATH DIRNAME/BASENAME.mp3

@strong{4} parallel lame -V 2 FULLPATH DIRNAME/BASENAME.mp3 ::: ~/Music/*.wav 

@node DIFFERENCES BETWEEN jobflow AND GNU Parallel
@section DIFFERENCES BETWEEN jobflow AND GNU Parallel

@strong{jobflow} can run multiple jobs in parallel.

Just like @strong{xargs} output from @strong{jobflow} jobs running in parallel mix
together by default. @strong{jobflow} can buffer into files (placed in
/run/shm), but these are not cleaned up - not even if @strong{jobflow} dies
unexpectently. If the total output is big (in the order of RAM+swap)
it can cause the system to run out of memory.

@strong{jobflow} gives no error if the command is unknown, and like @strong{xargs}
redirection requires wrapping with @strong{bash -c}.

@strong{jobflow} makes it possible to set ressource limits on the running
jobs. This can be emulated by GNU @strong{parallel} using @strong{bash}'s @strong{ulimit}:

@verbatim
  jobflow -limits=mem=100M,cpu=3,fsize=20M,nofiles=300 myjob

  parallel 'ulimit -v 102400 -t 3 -f 204800 -n 300 myjob'
@end verbatim

@menu
* EXAMPLES FROM jobflow README::
@end menu

@node EXAMPLES FROM jobflow README
@subsection EXAMPLES FROM jobflow README

@strong{1} cat things.list | jobflow -threads=8 -exec ./mytask @{@}

@strong{1} cat things.list | parallel -j8 ./mytask @{@}

@strong{2} seq 100 | jobflow -threads=100 -exec echo @{@}

@strong{2} seq 100 | parallel -j100 echo @{@}

@strong{3} cat urls.txt | jobflow -threads=32 -exec wget @{@}

@strong{3} cat urls.txt | parallel -j32 wget @{@}

@strong{4} find . -name '*.bmp' | jobflow -threads=8 -exec bmp2jpeg @{.@}.bmp @{.@}.jpg

@strong{4} find . -name '*.bmp' | parallel -j8 bmp2jpeg @{.@}.bmp @{.@}.jpg

@node DIFFERENCES BETWEEN gargs AND GNU Parallel
@section DIFFERENCES BETWEEN gargs AND GNU Parallel

@strong{gargs} can run multiple jobs in parallel.

It caches output in memory. This causes it to be extremely slow when
the output is larger than the physical RAM, and can cause the system
to run out of memory.

See more details on this in @strong{man parallel_design}.

Output to stderr (standard error) is changed if the command fails.

Here are the two examples from @strong{gargs} website.

@strong{1} seq 12 -1 1 | gargs -p 4 -n 3 "sleep @{0@}; echo @{1@} @{2@}"

@strong{1} seq 12 -1 1 | parallel -P 4 -n 3 "sleep @{1@}; echo @{2@} @{3@}"

@strong{2} cat t.txt | gargs --sep "\s+" -p 2 "echo '@{0@}:@{1@}-@{2@}' full-line: \'@{@}\'"

@strong{2} cat t.txt | parallel --colsep "\\s+" -P 2 "echo '@{1@}:@{2@}-@{3@}' full-line: \'@{@}\'"

@node DIFFERENCES BETWEEN orgalorg AND GNU Parallel
@section DIFFERENCES BETWEEN orgalorg AND GNU Parallel

@strong{orgalorg} can run the same job on multiple machines. This is related
to @strong{--onall} and @strong{--nonall}.

@strong{orgalorg} supports entering the SSH password - provided it is the
same for all servers. GNU @strong{parallel} advocates using @strong{ssh-agent}
instead, but it is possible to emulate @strong{orgalorg}'s behavior by
setting SSHPASS and by using @strong{--ssh "sshpass ssh"}.

To make the emulation easier, make a simple alias:

@verbatim
  alias par_emul="parallel -j0 --ssh 'sshpass ssh' --nonall --tag --linebuffer"
@end verbatim

If you want to supply a password run:

@verbatim
  SSHPASS=`ssh-askpass`
@end verbatim

or set the password directly:

@verbatim
  SSHPASS=P4$$w0rd!
@end verbatim

If the above is set up you can then do:

@verbatim
  orgalorg -o frontend1 -o frontend2 -p -C uptime
  par_emul -S frontend1 -S frontend2 uptime

  orgalorg -o frontend1 -o frontend2 -p -C top -bid 1
  par_emul -S frontend1 -S frontend2 top -bid 1

  orgalorg -o frontend1 -o frontend2 -p -er /tmp -n 'md5sum /tmp/bigfile' -S bigfile
  par_emul -S frontend1 -S frontend2 --basefile bigfile --workdir /tmp  md5sum /tmp/bigfile
@end verbatim

@strong{orgalorg} has a progress indicator for the transferring of a
file. GNU @strong{parallel} does not.

@node DIFFERENCES BETWEEN Rust parallel AND GNU Parallel
@section DIFFERENCES BETWEEN Rust parallel AND GNU Parallel

Rust parallel implements a few features from GNU @strong{parallel}, but
lacks many functions. All of these fail:

@verbatim
  # -q to protect quoted $ and space
  parallel -q perl -e '$a=shift; print "$a"x10000000' ::: a b c
  # Generation of combination of inputs
  parallel echo {1} {2} ::: red green blue ::: S M L XL XXL
  # Show what would be executed
  parallel --dry-run echo ::: a
  # Run different shell dialects
  zsh -c 'parallel echo \={} ::: zsh && true'
  csh -c 'parallel echo \$\{\} ::: shell && true'
  bash -c 'parallel echo \$\({}\) ::: pwd && true'
@end verbatim

Rust parallel lacks @strong{::::}, @strong{--pipe}, and has no remote facilities.

Rust parallel buffers in RAM like gargs. This can cause
death-by-swapping. See @strong{man parallel_design}.

@node DIFFERENCES BETWEEN ClusterSSH AND GNU Parallel
@section DIFFERENCES BETWEEN ClusterSSH AND GNU Parallel

ClusterSSH solves a different problem than GNU @strong{parallel}.

ClusterSSH opens a terminal window for each computer and using a
master window you can run the same command on all the computers. This
is typically used for administrating several computers that are almost
identical.

GNU @strong{parallel} runs the same (or different) commands with different
arguments in parallel possibly using remote computers to help
computing. If more than one computer is listed in @strong{-S} GNU @strong{parallel} may
only use one of these (e.g. if there are 8 jobs to be run and one
computer has 8 cores).

GNU @strong{parallel} can be used as a poor-man's version of ClusterSSH:

@strong{parallel --nonall -S server-a,server-b do_stuff foo bar}

@node BUGS
@chapter BUGS

@menu
* Quoting of newline::
* Speed::
* --nice limits command length::
* Aliases and functions do not work::
@end menu

@node Quoting of newline
@section Quoting of newline

Because of the way newline is quoted this will not work:

@verbatim
  echo 1,2,3 | parallel -vkd, "echo 'a{}b'"
@end verbatim

However, these will all work:

@verbatim
  echo 1,2,3 | parallel -vkd, echo a{}b
  echo 1,2,3 | parallel -vkd, "echo 'a'{}'b'"
  echo 1,2,3 | parallel -vkd, "echo 'a'"{}"'b'"
@end verbatim

@node Speed
@section Speed

@menu
* Startup::
* Job startup::
* SSH::
* Disk access::
@end menu

@node Startup
@subsection Startup

GNU @strong{parallel} is slow at starting up - around 250 ms the first time
and 150 ms after that.

@node Job startup
@subsection Job startup

Starting a job on the local machine takes around 10 ms. This can be a
big overhead if the job takes very few ms to run. Often you can group
small jobs together using @strong{-X} which will make the overhead less
significant. Or you can run multiple GNU @strong{parallel}s as described in
@strong{EXAMPLE: Speeding up fast jobs}.

@node SSH
@subsection SSH

When using multiple computers GNU @strong{parallel} opens @strong{ssh} connections
to them to figure out how many connections can be used reliably
simultaneously (Namely SSHD's MaxStartups). This test is done for each
host in serial, so if your @strong{--sshloginfile} contains many hosts it may
be slow.

If your jobs are short you may see that there are fewer jobs running
on the remove systems than expected. This is due to time spent logging
in and out. @strong{-M} may help here.

@node Disk access
@subsection Disk access

A single disk can normally read data faster if it reads one file at a
time instead of reading a lot of files in parallel, as this will avoid
disk seeks. However, newer disk systems with multiple drives can read
faster if reading from multiple files in parallel.

If the jobs are of the form read-all-compute-all-write-all, so
everything is read before anything is written, it may be faster to
force only one disk access at the time:

@verbatim
  sem --id diskio cat file | compute | sem --id diskio cat > file
@end verbatim

If the jobs are of the form read-compute-write, so writing starts
before all reading is done, it may be faster to force only one reader
and writer at the time:

@verbatim
  sem --id read cat file | compute | sem --id write cat > file
@end verbatim

If the jobs are of the form read-compute-read-compute, it may be
faster to run more jobs in parallel than the system has CPUs, as some
of the jobs will be stuck waiting for disk access.

@node --nice limits command length
@section --nice limits command length

The current implementation of @strong{--nice} is too pessimistic in the max
allowed command length. It only uses a little more than half of what
it could. This affects @strong{-X} and @strong{-m}. If this becomes a real problem for
you file a bug-report.

@node Aliases and functions do not work
@section Aliases and functions do not work

If you get:

@verbatim
  Can't exec "command": No such file or directory
@end verbatim

or:

@verbatim
  open3: exec of by command failed
@end verbatim

it may be because @emph{command} is not known, but it could also be
because @emph{command} is an alias or a function. If it is a function you
need to @strong{export -f} the function first. An alias will only work if
you use @strong{env_parallel}.

@node REPORTING BUGS
@chapter REPORTING BUGS

Report bugs to <bug-parallel@@gnu.org> or
https://savannah.gnu.org/bugs/?func=additem&group=parallel

See a perfect bug report on
https://lists.gnu.org/archive/html/bug-parallel/2015-01/msg00000.html

Your bug report should always include:

@itemize
@item The error message you get (if any).

@item The complete output of @strong{parallel --version}. If you are not running
the latest released version (see http://ftp.gnu.org/gnu/parallel/) you
should specify why you believe the problem is not fixed in that
version.

@item A minimal, complete, and verifiable example (See description on
http://stackoverflow.com/help/mcve).

It should be a complete example that others can run that shows the problem
including all files needed to run the example. This should preferably
be small and simple, so try to remove as many options as possible. A
combination of @strong{yes}, @strong{seq}, @strong{cat}, @strong{echo}, and @strong{sleep} can
reproduce most errors. If your example requires large files, see if
you can make them by something like @strong{seq 1000000} > @strong{file} or @strong{yes
| head -n 10000000} > @strong{file}.

If your example requires remote execution, see if you can use
@strong{localhost} - maybe using another login.

@item The output of your example. If your problem is not easily reproduced
by others, the output might help them figure out the problem.

@item Whether you have watched the intro videos
(http://www.youtube.com/playlist?list=PL284C9FF2488BC6D1), walked
through the tutorial (man parallel_tutorial), and read the EXAMPLE
section in the man page (man parallel - search for EXAMPLE:).

@end itemize

If you suspect the error is dependent on your environment or
distribution, please see if you can reproduce the error on one of
these VirtualBox images:
http://sourceforge.net/projects/virtualboximage/files/
http://www.osboxes.org/virtualbox-images/

Specifying the name of your distribution is not enough as you may have
installed software that is not in the VirtualBox images.

If you cannot reproduce the error on any of the VirtualBox images
above, see if you can build a VirtualBox image on which you can
reproduce the error. If not you should assume the debugging will be
done through you. That will put more burden on you and it is extra
important you give any information that help. In general the problem
will be fixed faster and with less work for you if you can reproduce
the error on a VirtualBox.

@node AUTHOR
@chapter AUTHOR

When using GNU @strong{parallel} for a publication please cite:

O. Tange (2011): GNU Parallel - The Command-Line Power Tool, ;login:
The USENIX Magazine, February 2011:42-47.

This helps funding further development; and it won't cost you a cent.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing.

Copyright (C) 2007-10-18 Ole Tange, http://ole.tange.dk

Copyright (C) 2008,2009,2010 Ole Tange, http://ole.tange.dk

Copyright (C) 2010,2011,2012,2013,2014,2015,2016 Ole Tange,
http://ole.tange.dk and Free Software Foundation, Inc.

Parts of the manual concerning @strong{xargs} compatibility is inspired by
the manual of @strong{xargs} from GNU findutils 4.4.2.

@node LICENSE
@chapter LICENSE

Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Free
Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
at your option any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

@menu
* Documentation license I::
* Documentation license II::
@end menu

@node Documentation license I
@section Documentation license I

Permission is granted to copy, distribute and/or modify this documentation
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts.  A copy of the license is included in the file fdl.txt.

@node Documentation license II
@section Documentation license II

You are free:

@table @asis
@item @strong{to Share}
@anchor{@strong{to Share}}

to copy, distribute and transmit the work

@item @strong{to Remix}
@anchor{@strong{to Remix}}

to adapt the work

@end table

Under the following conditions:

@table @asis
@item @strong{Attribution}
@anchor{@strong{Attribution}}

You must attribute the work in the manner specified by the author or
licensor (but not in any way that suggests that they endorse you or
your use of the work).

@item @strong{Share Alike}
@anchor{@strong{Share Alike}}

If you alter, transform, or build upon this work, you may distribute
the resulting work only under the same, similar or a compatible
license.

@end table

With the understanding that:

@table @asis
@item @strong{Waiver}
@anchor{@strong{Waiver}}

Any of the above conditions can be waived if you get permission from
the copyright holder.

@item @strong{Public Domain}
@anchor{@strong{Public Domain}}

Where the work or any of its elements is in the public domain under
applicable law, that status is in no way affected by the license.

@item @strong{Other Rights}
@anchor{@strong{Other Rights}}

In no way are any of the following rights affected by the license:

@itemize
@item Your fair dealing or fair use rights, or other applicable
copyright exceptions and limitations;

@item The author's moral rights;

@item Rights other persons may have either in the work itself or in
how the work is used, such as publicity or privacy rights.

@end itemize

@end table

@table @asis
@item @strong{Notice}
@anchor{@strong{Notice}}

For any reuse or distribution, you must make clear to others the
license terms of this work.

@end table

A copy of the full license is included in the file as cc-by-sa.txt.

@node DEPENDENCIES
@chapter DEPENDENCIES

GNU @strong{parallel} uses Perl, and the Perl modules Getopt::Long,
IPC::Open3, Symbol, IO::File, POSIX, and File::Temp. For remote usage
it also uses rsync with ssh.

@node SEE ALSO
@chapter SEE ALSO

@strong{ssh}(1), @strong{ssh-agent}(1), @strong{sshpass}(1), @strong{ssh-copy-id}(1),
@strong{rsync}(1), @strong{find}(1), @strong{xargs}(1), @strong{dirname}(1), @strong{make}(1),
@strong{pexec}(1), @strong{ppss}(1), @strong{xjobs}(1), @strong{prll}(1), @strong{dxargs}(1),
@strong{mdm}(1)

@bye
