Processing a list of files under bash

From: Michael C. (mcsuper5_at_usol.com)
Date: 08/06/04


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.


Relevant Pages

  • Re: Obtaining random seeds
    ... cat /dev/mouse | od ... >>command line under some Unix flavor. ... >>not include things like hash functions, ... > I get the number by executing a bunch of commands ...
    (sci.crypt)
  • Re: Processing a list of files under bash
    ... > I've built a file (output from ImageMagick's identify command, hash is ... > from the listing ($tmp1) that sed processes. ...
    (alt.os.linux)
  • Re: directory listing without ls
    ... you lose the /usr partition or the "ls" command how would you list a ... cat is *not* built into the shell. ...
    (comp.unix.shell)
  • Re: Command Button Wizard
    ... make sure the database is in a trusted location via: ... > built with the Wizard all work. ... > settings) and the command buttons built with the Wizard will not work - ...
    (microsoft.public.access.formscoding)
  • Re: Adding a -D date option to `cat
    ... So, instead of adding 800 bytes to 'cat', we should create a new ... command with a new name, and increase the size of the base system ... singing and all-dancing command for filtering. ... port which I know that no one will ever use, ...
    (freebsd-current)