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

RedHat 7.1 script problem

Status
Not open for further replies.

KarveR

MIS
Dec 14, 1999
2,065
GB
Hi all, Im having fun (NOT) with this little monkee:

#!/bin/sh

$i=1
im=image
ext=".jpg"

ls -l *.jpg|awk '{ print $9 }' > imagelist
images=`grep '^' imagelist`
for image in $images
do

cp $image "image"$i".jpg"
i=`expr $i + 1`
done

I get the following error(s)
cp: cannot stat `119051.jpg\r\r': No such file or directory
where 119051.jpg is an image .. where does it get the \r\r from?
and
expr: non-numeric argument but the i=`expr $i + 1` works fine in a different script.

Open to suggestions thanks :) ***************************************
Party on, dudes!
[cannon]
 
NM sorted
---------------------------------------------
#!/bin/sh
set -x

i=1
ls -l *.jpg |awk '{ print $9 }' > imagelist

images=`grep '^' imagelist`
for image in $images
do
echo $image , $i
mv $image image$i.jpg
i=`expr $i + 1`
done

chmod 777 * ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top