1834414 Members
1485 Online
110067 Solutions
New Discussion

Re: Script to copy file

 
SOLVED
Go to solution
Stephen Ng
Occasional Advisor

Script to copy file

The following script works on other Unix OS but not HP/UX:
#!/bin/ksh

for i in cat flist
do
cp ./$i ./newdir/$i
done
exit

where filst is a text file with one filname per line
4 REPLIES 4
Scott Van Kalken
Esteemed Contributor
Solution

Re: Script to copy file

try

for i in `cat flist`

Scott Van Kalken
Esteemed Contributor

Re: Script to copy file

you could even try:

go()
{
while read file
do
cp $file ./newdir/$file
done
}

go < flist

Stephen Ng
Occasional Advisor

Re: Script to copy file

Scott,
It works.
Tks
Gerhard Roets
Esteemed Contributor

Re: Script to copy file

It is recomended to put $i in double quotes, if i has a space in it it could cause major hickups.

Hence change all $i to "$i". As a general note under unix scripts put all variable substitutions in double quotes.

Regards
Gerhard