Search code examples
linuxbashparallel-processingparallel.foreachgnu-parallel

Using BASH FOR LOOP and PARALLEL


Just want to check if this is possible to automate in PRALLEL?. I have a bash script that reads a text file line per line and then takes the word of that line as a parameter then it will be processed by the bash script. For sample this would be the format of the text file

TEXT FILE

# cat test.txt
dog
cat
fish
rat
dove

Then line per line will be executed by a separate bash script via loop fashion like these

# for word in `cat test.txt`; do ./MY-BASH-SCRIPT.sh ${word}; done

Well this works fine however I it is executed one by one. May I ask for any suggestion on how can I possibly trigger the words in PRALLEL? I've gone and also read the GNU Parallel and gone some test however got no luck yet


Solution

  • this is now solved via parallel command:

    cat test.txt | parallel ./MY-BASH-SCRIPT.sh {}