Search code examples
shellgnu-parallel

multiple arguments at a time with gnu parallel


Is it possible to have GNU parallel to call a command with multiple arguments at a time, up to some limit?

Just for explanations sake, a simple example...

Make some files: seq 10 | parallel touch test_files{}.txt

To remove them, I could do: rm ./test_files*.txt,

or equivalently with GNU parallel: ls ./test_files*.txt | parallel rm, which runs rm once for each file.

Is there some way to tell GNU parallel to run the command with a max-number of arguments, like...

ls ./test_files*.txt | parallel --max-args 5 rm

that would launch

rm test_files1.txt test_files2.txt test_files3.txt test_files4.txt test_files5.txt
rm test_files6.txt test_files7.txt test_files8.txt test_files9.txt test_files10.txt

Solution

  • $ seq 10 | parallel --max-args 5 echo
    1 2 3 4 5
    6 7 8 9 10