Search code examples
escapingcurly-bracesgnu-parallel

How to escape brace in gnu-parallel


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

Solution

  • Use -I to change {} into something else:

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