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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

kshell script: brackets in for loop

Status
Not open for further replies.

starlite79

Technical User
Aug 15, 2008
89
US
Hi,

I have a script that runs successfully on an old HP-UX system as a shell script, though on Linux it seems it needs to be a kshell script.

In any case, I have several files that start as a few letters (like myname) and end with two digits 0-9 (so the possible file names can be myname00-99, inclusive).

The following syntax works on HP-UX but NOT on my Linux machine:

for FILE in myname[0-9][0-9]
do...

How do I use those brackets in a for loop? Do I need double brackets instead?

Thanks for your help!
 
What about this ?
for FILE in myname??

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi, Feherke,

I am pretty sure it is that line. During testing, I had gotten a ``myname[0-9][0-9]'' file created, which was not what I wanted.

PHV, I will give the ?? a try and update later.
 
You may try this:
for FILE in $(ls myname[0-9][0-9])

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top