Date: Thu, 26 Apr 2007 07:31:30 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Irsla <irsla42@gmail.com> Cc: FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Re: first of misc questions.... Message-ID: <46304742.8060205@infracaninophile.co.uk> In-Reply-To: <ed5f4bce0704251331v735ccedet947318e8d2a6fbe1@mail.gmail.com> References: <20070425072914.GA65634@thought.org> <462F0824.5000107@infracaninophile.co.uk> <ed5f4bce0704251331v735ccedet947318e8d2a6fbe1@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Irsla wrote: > Hi, > > On 4/25/07, Matthew Seaman <m.seaman@infracaninophile.co.uk> wrote: >> >> find . -type f \( -mtime 6 -o -mtime 29 \) -print0 | xargs -0 vi >> > > what about the -exec option of find ? I always wonder why people don't > use it. > > find . -type f \( -mtime 6 -o -mtime 29 \) -exec vi {} \; > The critical difference is that 'find | xargs foo' runs foo once[*], to process all the files in one go. 'find -exec foo {}' runs foo one time for each matched file. In this case, it's probably not a big deal, but when you need to process hundreds of files 'find | xargs foo' is much more efficient. Cheers, Matthew [*] Actually, it runs foo repeatedly with as many filenames on the foo command line as it can each time. That's generally several hundred files at a go. - -- Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.3 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGMEdC8Mjk52CukIwRCC97AJwPY6m5uHCQ/AvdnyjceQZDDtvmngCgi0RV Im64VTob1mZRGtczhMIAaRQ= =RaJi -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46304742.8060205>