Processing a list of files under bash
From: Michael C. (mcsuper5_at_usol.com)
Date: 08/06/04
- Next message: Jemy: "fedora mail service"
- Previous message: Matt_left_coast: "Re: How to disable X server"
- Next in thread: Bill Marcum: "Re: Processing a list of files under bash"
- Reply: Bill Marcum: "Re: Processing a list of files under bash"
- Reply: Chris F.A. Johnson: "Re: Processing a list of files under bash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 6 Aug 2004 07:17:18 GMT
I'm stuck.
I've built a file (output from ImageMagick's identify command, hash is
shortened since it isn't part of the problem)
cat delete.me
abb47bbefc25a070ca 316x435 23338b "file two.jpg"
abb47bbefc25a070ca 316x435 23338b "file one.jpg"
************
I need to delete the listed files, and remove those names from a
different file. The code below fails to remove files if a space is in
the name, and apparently removes "file three.gif" and "forty one.jpg"
from the listing ($tmp1) that sed processes.
Can anyone point me in the right direction? Suggestions, short of not
using spaces in the filenames (I don't, but some of the images I've
acquired have them, and a simple conversion would likely result in
file name collisions.)
*** code ***
tmp1=tmp1
tmp2=tmp2
for i in `cut -d' ' -f 4- delete.me` ;
do
# remove file
echo "$i"
rm $safe "$i"
# remove filename from the text file
sed -e "/$i/d" ${tmp1} > ${tmp2} ;
sync ; # shouldn't be required, but aside from time
# shouldn't hurt.
cp ${tmp2} ${tmp1} ;
done
*** out ***
"file
rm: cannot remove `"file': No such file or directory
two.jpg"
rm: cannot remove `one.jpg"': No such file or directory
"file
rm: cannot remove `"file': No such file or directory
one.jpg"
rm: cannot remove `one.jpg"': No such file or directory
TIA,
Michael C.
-- mcsuper5@usol.com http://mcsuper5.freeshell.org/ Experience is what causes a person to make new mistakes instead of old ones.
- Next message: Jemy: "fedora mail service"
- Previous message: Matt_left_coast: "Re: How to disable X server"
- Next in thread: Bill Marcum: "Re: Processing a list of files under bash"
- Reply: Bill Marcum: "Re: Processing a list of files under bash"
- Reply: Chris F.A. Johnson: "Re: Processing a list of files under bash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|