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

Need Help for a script

Status
Not open for further replies.

geoav

Programmer
Oct 31, 2002
11
GR
Hello to everyone. I'm trying to execute a script which on unix works perfect but when i try to run it in redhat linux it doesn't work correctly. One of the main problems is that it doesn't seem to understand the wildcards. The scripts goes like that :
#!/bin/sh
testdir=/home/george/testdir/
.
.
.
for rep in /home/george/test*
do
mv ${rep} ${testdir}
echo ${rep}
done

Although the folder /home/george has many files like test*
it moves none and it prints on screen "/home/george/test*" , which means that it goes once in the for loop and then nothing. Anybody knows what i can do to solve this problem?
Thanks anyway
 
Hi,

Put this instead:

#!/bin/sh
testdir=/home/george/testdir/
.
.
.
for rep in `ls /home/george/test*`
do
mv ${rep} ${testdir}
echo ${rep}
done

regards,
feroz
 
Thanx a lot. That was it. Only I am wondering. I thought that it was supposed to be regardless of unix version or linux version the same for each sell eg bash or sh. But now i find out that it depends on the version. Was i so wrong?
 
Hi,

What UNIX flavour do you use before?

regards,
feroz
 
I don't know. It was on a client of our company and i had to create some scripts so since we didn't have an installation of unix here we decided to install linux as a ways to have something similar to the customer's enviroment. Anyway it doesn't really matter.
Thanx a lot again.
My best regards
George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top