1

I have a c++ program that needs command line arguments like this

./Program textfile.txt argu1 10 

It then gives an output on command line, using cout.

However, is there an easy way of inputting

./Program textfile.txt argu1 10 
./Program textfile.txt argu1 20 
./Program textfile.txt argu1 30 

I need the output in a text file because I need to run 100 of these.

I rather not do it manual...

Gaurav
  • 358
  • 5
  • 18
  • 1
    possible duplicate of [How do I write a for loop in bash](http://stackoverflow.com/questions/49110/how-do-i-write-a-for-loop-in-bash) – user657267 Apr 21 '14 at 04:13
  • What do you mean by `output`? There is nothing in your question that even references an `output`.. – MrDuk Apr 21 '14 at 04:13

1 Answers1

1

If you are working in bash shell, you can use:

for i in $(seq 10 10 1000)
do
  ./Program textfile.txt $i >> ouitput.txt
done
R Sahu
  • 204,454
  • 14
  • 159
  • 270
  • and to output to a file, use `./Program textfile.txt $i >> ./output.txt` to append each result to `./output.txt` Make sure you use an `endl` at the end of the last `cout` so the results end up on different lines on the output file. – vsoftco Apr 21 '14 at 04:18
  • @vsoftco Thanks for the hint. The answer is updated. – R Sahu Apr 21 '14 at 04:21