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.

User12345
  • 5,180
  • 14
  • 58
  • 105

1 Answers1

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.

Inian
  • 80,270
  • 14
  • 142
  • 161