1

I have a shell script called test.sh and a argument file called xaa in a directory. Location of the directory is /home/$USER/par

To run this script I am doing

cd /home/$USER/par 

and then

./test.sh xaa 

Until now the script works fine

Now I want to run the same test.sh script for different argument files like xab, xac, xad and so on at the same time.

what I want is to invoke test.sh

./test.sh xaa ./test.sh xab ./test.sh xac ./test.sh xad 

all at the same time from one terminal only.

How can I achieve my requirement.

1
  • xargs to the rescue! Commented Jan 3, 2018 at 17:28

1 Answer 1

3

The simplest of the ways to do this would be to use the & notation to put them as background processes.

for arg in xaa xab xac xad; do ./test.sh "$arg" & done 

You could also read up the parallelization techniques provided by xargs or GNU parallel for more computation intensive tasks.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.