On Tue, 2007-03-20 at 09:50 -0600, Phillip Hellewell wrote:
> 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?:

I messed it up.

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

Correct.

> 
> 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
> 

--------------------
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