-exec on find(1) broken

Marty Leisner leisner@rochester.rr.com
Wed Oct 10 06:10:00 GMT 2007


Brian Dessent <brian@dessent.net> writes  on Tue, 09 Oct 2007 02:51:23 PDT
     > Paul McFerrin wrote:
     > 
     > > Well, I finally got it!
     > > 
     > >      find . -type f -mtime +18 -exec /bin/echo {} \; | more
     > > 
     > > is the correct syntax.  Now I just replace "/bin/echo" with "/bin/rm"
     > > and I ready to go.
     > 
     > That's still horribly overcomplicated and inefficient.  Use "find .
     > -type f -mtime +18" to see what the results would be and "find . -type f
     > -mtime +18 -delete" to delete them.  It's much more efficient to let
     > find do the deleting than worrying about creating a bunch of echo or rm
     > child processes.
     > 

Geez, thanks Brian...I've been using find for 25 years and never realized it had 
a delete option .

I stay away from exec -- you can often do what you need with find -- or
format output with -printf to do special formatting...

I often used -exec with cp/mv -- but coreutils has an option (-t) so you 
can put these after xargs...

marty



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list