Differences between revisions 8 and 9
Revision 8 as of 2018-11-15 05:38:13
Size: 940
Editor: SamatJain
Comment: -n option
Revision 9 as of 2019-02-12 08:04:49
Size: 1208
Editor: SamatJain
Comment: Clarify -m, mention preference for -X. parallel w/ file of arguments.
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
parallel -m mp3check -Sqe ::: *mp3 parallel -X mp3check -Sqe ::: *mp3
Line 11: Line 11:

# Using a file (one per line) of arguments
parallel 'some-command {}' ::: list-of-arguments.txt
Line 22: Line 25:
 * `-X`: Multiple arguments per job, distributed evenly
 * `--xargs`: Emulates xargs behavior; as many arguments per job as possible
 * `-n`: Limits number of arguments per job, use w/ `-X` and `--xargs`
 * `-X`: Multiple arguments per job, spread evenly across jobs, with context replace to replace "{}".
 * `-m`: Multiple arguments per job, sprea
d evenly across jobs. Preferably use `-X`.
 * `--xargs`: Multiple arguments per job emulating xargs behavior; as many arguments per job as possible

 * `-n`: Limits number of arguments per job, use w/ `-X`, `--xargs`, or `-m`

   1 # Parallel copy
   2 # Because we are copying the current directory, make sure $dst is correct
   3 find . -maxdepth 1 -mindepth 1 -print0 | parallel -q0 -j4 echo cp -avn {} $dst
   4 
   5 # Check MP3s in parallel, many arguments per invocation
   6 parallel -X mp3check -Sqe ::: *mp3
   7 
   8 # Run commands in a file parallel
   9 parallel < commands.txt
  10 
  11 # Using a file (one per line) of arguments
  12 parallel 'some-command {}' ::: list-of-arguments.txt
  13 
  14 # Parallel equivalent of
  15 # `find $DIRECTORY -type f -exec sha1sum '{}' \; > $DIRECTORY.sha1`
  16 find $DIRECTORY -type f -print0 | parallel -q0 -k sha1sum > $DIRECTORY.sha1
  17 
  18 # Quickly get hash of large file. Reads in 1G chunks, multiple CPUs, and outputs 1 hash.
  19 parallel --block=1G --pipepart -a $LARGE_FILE --progress --recend '' -k sha1sum | sha1sum

  • -X: Multiple arguments per job, spread evenly across jobs, with context replace to replace "{}".

  • -m: Multiple arguments per job, spread evenly across jobs. Preferably use -X.

  • --xargs: Multiple arguments per job emulating xargs behavior; as many arguments per job as possible

  • -n: Limits number of arguments per job, use w/ -X, --xargs, or -m

SamatsWiki: CheatSheet/GNUParallel (last edited 2019-04-28 00:16:11 by SamatJain)