Jump to content
  • Advertisement
Sign in to follow this  

Producing numbered files in shell (very simple)

This topic is 4151 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
You can use expr.

for f in $(cat $1)
grep $f $2 > $2_$i
i=`expr $i + 1`

Hope this helps.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!