4

I have a python script that I want to call using gnu-parallel this way:

parallel run_script.py --outfile=/path/to/somewhere/{}/{}.nc --shift={} ::: 1 2 3

How can I escape the first curly brace in [--outfile] to be used for python string formatting ?

Expected results:

parallel --dry-run run_script.py --outfile=/path/to/somewhere/{}/{}.nc --shift={} ::: 1 2 3
run_script.py --outfile=/path/to/somewhere/{}/{}.nc --shift=1
run_script.py --outfile=/path/to/somewhere/{}/{}.nc --shift=2
run_script.py --outfile=/path/to/somewhere/{}/{}.nc --shift=3
Nicolas
  • 43
  • 3

1 Answers1

3

Use -I to change {} into something else:

parallel -I ,, --dry-run run_script.py --outfile=/path/to/somewhere/{}/{}.nc --shift=,, ::: 1 2 3
Ole Tange
  • 31,768
  • 5
  • 86
  • 104
  • @Nicolas May I instead suggest you walk through `man parallel_tutorial` once a year? – Ole Tange Mar 03 '17 at 10:05
  • The more direct answer to the question, ie "escaping curly brace" with '\' could be of use, since -I does not duplicate all the functionalities of {*} replacement strings. `parallel 'echo "First:"\{\} && { echo "Second:{}" ; }' ::: 123` outputs `First:{} Second:123` – macieksk Nov 29 '18 at 22:38