Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNU Parallel: how to pass job id to command

Tags:

gnu-parallel

Suppose I am running gnu parallel on an array of items received from standard in, and split according to some criteria:

cat content | parallel -j 4 my_command

How do I access the job number such that I can pass into command, as an argument, the job number/id of the parallel execution (so that each parallel execution block has a unique number):

cat content | parallel -j 4 my_command -n ???

(Is this even possible? Reviewing the man pages at the moment)

like image 508
Chris Avatar asked Oct 16 '22 05:10

Chris


1 Answers

You are looking for the replacement string {#}

cat content | parallel -j 4 my_command -n {#}

It is also mentioned on the cheat sheet: https://www.gnu.org/software/parallel/parallel_cheat.pdf

like image 194
Ole Tange Avatar answered Oct 21 '22 07:10

Ole Tange