delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/10/10/02:10:38

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-Id: <200710100610.l9A6ADDk029020@dell2.home>
To: cygwin AT cygwin DOT com, Brian Dessent <brian AT dessent DOT net>
cc: leisner AT rochester DOT rr DOT com
Subject: Re: -exec on find(1) broken
In-reply-to: <470B4F1B.3AD3BCB8@dessent.net>
References: <470B1B1B DOT 2060404 AT columbus DOT rr DOT com> <20071009062547 DOT GA19172 AT suncomp1 DOT spk DOT agilent DOT com> <470B22FF DOT 10107 AT columbus DOT rr DOT com> <470B288E DOT 8060504 AT columbus DOT rr DOT com> <470B4F1B DOT 3AD3BCB8 AT dessent DOT net>
Comments: In-reply-to Brian Dessent <brian AT dessent DOT net> message dated "Tue, 09 Oct 2007 02:51:23 -0700."
MIME-Version: 1.0
Date: Wed, 10 Oct 2007 02:10:13 -0400
From: "Marty Leisner" <leisner AT rochester DOT rr DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Brian Dessent <brian AT dessent DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019