James Haynes
James Haynes

Reputation: 25

Iterating in Bash by Array

I am unfamiliar with bash and I am running into some issues. I want to change the program's first parameter to 1 4 8 16 and for each of those parameters I want to want it to change the second parameter to 100 and 500 and then run the program 25 times each.

This my attempt to write the script using scripts found in Google.

Anyone know how I can do this?

iarray=(1 4 8 16)
jarray=(100 500)

for i in "${iarray[@]}"
    do
    for j in "${jarray[@]}"
    do
        echo Threads: $i Matrix Size: $j

        for k in {1..25}
        do
            ./omp_task3fix.o $i $j 0
        done

        echo
    done
done

Upvotes: 1

Views: 104

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798676

Arrays are $IFS-delimited, not comma-delimited. And assignment to variables can't have spaces around the equals sign.

iarray=(1 4 8 16)
jarray=(100 500)

Upvotes: 3

Related Questions