Shell Scripts

We often need to run programs repeatedly with different command line arguments.

For example, we may want to run program3.go repeatedly as follows:
./program3 2 3
./program3 3 3
./program3 4 3
./program3 2 4
./program3 3 4

. . .

In bash this is done using a shell script (created using an ordinary text editor.)

The following script is called

go build program3.go
for (( j=3 ; j <= 5 ; j++ ))
   for (( i=2 ; i <= 4 ; i++ ))
      ./program3 $i $j

The first line of the script:#!/bin/bashtells your system to use the bash shell to execute the commands that follow.

Be sure to make the script executable with the command
chmod u+x

The script is executed thus: