[Gllug] bash string confusion
Craig Millar
gllug at craigmillar.org
Wed Jul 6 15:34:58 UTC 2005
Am trying to write a small bash script to check which stock items in our
inventory have not yet been illustrated. So, I get a dump of stock numbers
out of the database (filemaker - won't get started on that) and compare them
to the numbered images in the folder. Only, it is not working and I am
absolutely stumped:
for i in `cat photo.txt`; do
if test ! -e "$IMAGEDIR/$i.jpg" ; then
echo $i >> unillustrated.txt
fi
done
It returns all the records. As I know there are several thousand photographs
in the image folder, this is definitely not correct.
So, I echo the resultant test using
j="$i.jpg"; echo $j
in the for loop and too my utmost surprise it is returning the image names
with the .jpg suffix at the beginning, for example: .jpg0
If I pipe the output to less, I get something sort of resembling what I am
after, for eg: 59034^M.jpg - whither the ^M? Have opened up the file in vi -
sometimes filemaker throughs up all sorts of strange characters - can't see
any strange line breaks or the file though - certainly no ^Ms when i tried to
remove them.
Please somebody tell me where I am going wrong - googled to no effect and
it's driving me mad. Have tried a zillion string combinations and I'm sure
I'm just being lame.
Thanks!
Craig
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list