On Mon, Mar 19, 2007 at 03:39:19PM -0600, Michael L Torrie wrote:
> 
> find *.txt | while read f; do rm "$f" ; done
> 
> That avoids the problem of the commandline being too long (shell
> expansion will sometimes cause your command to fail if there are too
> many files.

Cool, I like the pipe while approach.  But does what you wrote really
avoid the command-line being too long?  Wouldn't you have to write this
instead?:

find -name "*.txt" | while read f; do rm "$f" ; done

It's a subtle difference, but I believe what you wrote above could still
have the problem since the *.txt would be expanded by the shell before
being passed to find.

Phillip

P.S.  Of course, there is another difference which is that what I wrote
does a recursive search.  So to prevent that you can do:

find -name "*.txt" -maxdepth 1 | while read f; do rm "$f" ; done

-- 
Phillip Hellewell <phillip AT hellewell.homeip.net>
--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to