On Fri, Nov 02, 2001 at 05:10:54PM +1100, Andrew Foster wrote:
> Hi all,
> 
> I was interested to hear your thoughts on solving a practical problem I
> have, while using only shell tools.. that is, not using Perl or Python
> or what have you.
> 
> So, I have a list of random filenames in a text file:
> 
>       thing.mp3
>       pants.txt
>       yer.rtf
>       others.html
> 
> These files do exist on my system, except they're scattered throughout a
> directory tree hierachy, and there's no path info in my text file to say
> where. 
> 
> I need to find the given files in the tree, then do stuff with them. For
> instance, delete them.

One way is

        for file in files.txt
        do
                find / -name $file -exec doStuff.sh {} \; 2>/dev/null
        done

where files.txt is you list of files and doStuff.sh is a shell script
that does stuff to the file in its first argument ($1).

Some small modifications may be necessary if the filenames have spaces
in them (some quoting and whatnot) and it will take _ages_, since all
those searches go from root, but it will get the problem solved (for
certain untested values of "will get the problem solved").

There will be other ways and this thread will never end.

Cheers,
Malcolm

-- 
Many are called, few volunteer.

-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to