"Double Loop" in shell. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

"Double Loop" in shell.

Hey guys I am trying to write a .sh file, looks like this: #!/bin/sh # simps.sh # for x in 10 100 1000 10000 do for n in 11 101 1001 10**4 + 1 10**5 + 1 10**6 + 1 10**7 + 1 do (./simps | tail -n 1) << ! $x $n ! ! done ** The idea is that I want it to call the .c code, provide the x value, and for that x value run the .c code with different n values.

5th Feb 2019, 8:33 PM
Sebastian Reyna
Sebastian Reyna - avatar
1 Answer
0
And how is it behaving at the moment? I'm not too familiar with bash shell scripting. What are the ! 's doing? And what are the for loops supposed to be doing with that syntax? Will it loop through 0 to 10 then 0 to 100 etc ? You also need to put 'done' after the inner loop as well.
6th Feb 2019, 12:35 AM
Zeke Williams
Zeke Williams - avatar