4

I'm trying to run something like this

for n in 1 2 3 4 5 6 7
     do 
           run_this_command whatever.$nx$n.in
     done

The files are named as whatever.1x1.in, whatever.2x2.in, whatever.3x3.in, etc.

The code I copied below does not work. How do I make it so I can have "nxn" in the file name inside the for loop?

4

Inside the loop, you want:

run_this_command "whatever.${n}x${n}.in"

so that the shell knows you're talking about $n, and not $nx.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.