This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -exec on find(1) broken


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]