Pass the same file to several parallel unix commands that all run different Perl scripts Pass the same file to several parallel unix commands that all run different Perl scripts unix unix

Pass the same file to several parallel unix commands that all run different Perl scripts


With GNU Parallel

parallel perl {} textfile.txt ::: myscript*.pl

Run with parallel --dry-run ... first if you want to see what it would do, but without actually doing anything.

Note that if you have 4 CPU cores, it will start 4 jobs in parallel and then start a new one each time a job finishes, and that is subtly different from having all running at once. If you have, say 32 jobs but only 4 cores and all 32 should be running at once, use parallel -j 32 ... for example.


run_all_perl() (    perl_scripts=(      myscript1.pl  myscript2.pl  myscript3.pl  myscript4.pl      myscript5.pl  myscript6.pl  myscript7.pl  myscript8.pl    )    for script in "${perl_scripts[@]}"; do        perl "$script" "$1" &    done    wait)run_all_perl textfile.txt