Well, this is a somewhat over-engineered Bash-solution, but it works and hopefully clarifies the use of the parallel
command:
function xx(){ curl "https://jsonplaceholder.typicode.com/todos/$1" > "$1.txt";}
parallel xx -- {1..100}
The first line creates a new "command" or function called xx
which - when executed - causes the execution of a curl command that has its stdout redirected to a file. The xx
function takes a single number as its argument; inside the body of the function, it is referred to as `$1', i.e. the first positional parameter.
The second line demonstrates the use of the parallel
command, which runs xx
once for (and with) each argument from the list 1, 2, 3, ..., 100 (the list 1 2 3 ... 100 is generated by the shell when it performs brace expansion on {1..100}
).
NOTE: this answer relates to the parallel
command in the moreutils
package on Debian systems, not to the GNU parallel
command.