Better way to write this script

Hi All,

I have written the following script. I have just repeated some commands, and I am sure there is a more better way to do it. I hope I one of gurus here will help me make it in a better shape. Here is the script:

#! /bin/sh

sed -i -e "s/test2.xxx/test3.xxx/" -e "s/output2/output3/" makeFV.C
root -l .x makeFV.C

sed -i -e "s/test3.xxx/test4.xxx/" -e "s/output3/output4/" makeFV.C
root -l .x makeFV.C

sed -i -e "s/test4.xxx/test5.xxx/" -e "s/output4/output5/" makeFV.C
root -l .x makeFV.C

sed -i -e "s/test5.xxx/test6.xxx/" -e "s/output5/output6/" makeFV.C
root -l .x makeFV.C

sed -i -e "s/test6.xxx/test7.xxx/" -e "s/output6/output7/" makeFV.C
root -l .x makeFV.C

sed -i -e "s/test7.xxx/test8.xxx/" -e "s/output7/output8/" makeFV.C
root -l .x makeFV.C

sed -i -e "s/test8.xxx/test9.xxx/" -e "s/output8/output9/" makeFV.C
root -l .x makeFV.C

Thanks in advance,

faizlo

What does "root -l .x makeFV.C" do?
If it doesn't modify the file, this is the same as your script:

sed -i -e "s/test[2-6].xxx/test7.xxx/" -e "s/output[2-6]/output7/" makeFV.C
root -l .x makeFV.C

On the other hand, if it has to be run between invocations of sed:

for n in 2 3 4 5 6
do
  n1=$(( $n + 1 ))
  sed -i.bak$n -e "s/test$n.xxx/test$n1.xxx/" -e "s/output$n/output$n1/" makeFV.C
  root -l .x makeFV.C
done

Thanks a lot,

yes, root -l .x makeFV.C should be invoked with each step.

faizlo