views:

72

answers:

2

Hi,

I am a newbie with shell scripting but just wanna quickly do something really simple. I have a testprogram that writes some results into a file "result". I wanna run the program three times and then store the results in an appropriate file with the name result1, result2, etc.

I thought something along those lines will do the trick:

for ((  i = 0 ;  i <= 3;  i++  ))
do
  ./testprogram
  cp result result+'i'    (?????)
  rm result
done

I am just not sure how I generate here the filename "result" + "i".

Sorry for this simple question

Alan

+6  A: 
cp result result$i
tur1ng
+9  A: 
for i in {1..3}
do
  ./testprogram
  mv results "result${i}"
done
ghostdog74
thank you so much ;)
Alan