I have a C application called Test. Test takes in a single int parameter. I want to run Test with many different parameters, so I made the following bash script:
#!/bin/bash
for i in {0..5}
do
./Test "$i"
done
However, this executes ./Test "$i" and not ./Test 0, ./Test 1 etc. Changing it to ./Test $i simply executes ./Test $i 5 times.What am I doing wrong?
Try
To create sequences in bash you can use
seq, which has an advantage of working in any bourne-compatible shell (that is,seqworks everywhere because it’s an external program, it’s theforloop that becomes more portable).Yes, it makes no difference with respect to
./Testinvocation, but it provides a respectful reason to procrastinate before fixing./Test.