1

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
1
  • 1
    your jarray initialization still has spaces around the =. Good luck. Commented Dec 10, 2013 at 1:15

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

2 Comments

It seems like I am close, but I get white space after Matrix Size: See above edited code.
@JamesHaynes, bash is very sensitive to whitespace -- you cannot put spaces around the = in an assignment. If you write var = 42, bash will attempt to execute the command "var" with 2 arguments, "=" and "42".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.