🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Producing numbered files in shell (very simple)

Started by
0 comments, last by let_bound 17 years ago
Hi, I am trying to write a script which will output files that are numbered. My draft script is this: #!/bin/sh LIST1=$1 LIST2=$2 for f in $(cat $1) do grep $f $2 > $2_???? done What I want is for all output files to be numbered e.g o1, o2, o3 etc etc, one for each line of input file $1. I am sure the answer is very simple but I cannot find it as I am a novice. Thanks, Christina
Advertisement
You can use expr.

#!/bin/shLIST1=$1LIST2=$2i=0for f in $(cat $1)do  grep $f $2 > $2_$i  i=`expr $i + 1`done


Hope this helps.

This topic is closed to new replies.

Advertisement