Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call different files in a loop.

Status
Not open for further replies.

scottpeter

Programmer
Sep 23, 2003
28
US
All,
I am new to Unix.I am trying to process 15 files in a shell script. The 15 files have the same name with the last characters as numbers 1 to 15.
I know that if it were a single digit number,I could have used [0-9]. But how will I call file ending with numbers above 9(from 10 to 15).
I cannot use *, because it will fetch some files that I do not need.
Also I cannot use a loop here. I need to call the files using a wild Card Character.

Thank You,
Scott
 
Thanks a lot Salem,
Just a doubt, if there were files upto 40, which would be more efficient. using above or by using
myprog file? file??

Thanks,
Scott

 
There's probably not a lot in it - wildcards are expanded by the shell prior to running myprog

As you've mentioned, simply saying
Code:
myprog *
drags along files you don't want.

You could say for example
Code:
myprog file[1-9] file[1-4][0-9]
which would get file1 to file49

The only real difficulty is how many sub-patterns it takes to specify all the files you want to process. I normally try and arrange by either directory contents and/or file names that
Code:
myprog file*
gets all the files I am interested in, in one easy step.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top