I have a bash loop where I am passing variables to a script. I want to run these in parallel with GNU parallel
for FILE_NAME in FILE1 FILE2 FILE3;
do
./SCRIPT -n $FILE_NAME
done
where I want the scripts to run in parallel as follows:
./SCRIPT -n FILE1
./SCRIPT -n FILE2
./SCRIPT -n FILE3
I am trying to use the GNU parallel command because it has been suggested a lot on here, but I am confused about where to put the parallel command if I am passing a variable to the script.
I have tried turning the FILE1 FILE2 FILE3
into a list:
parallel -a $FILE_LIST ./SCRIPT -n $FILE_NAME
for FILE_NAME in FILE1 FILE2 FILE3;
do
parallel ./SCRIPT -n $FILE_NAME
done
Do you have any suggestions?
Try like this:
parallel ./SCRIPT -n {} ::: FILE1 FILE2 FILE3
Or, more succinctly if your files are really named like that:
parallel ./SCRIPT -n {} ::: FILE*
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.