first of misc questions....

Matthew Seaman m.seaman at infracaninophile.co.uk
Thu Apr 26 06:31:46 UTC 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Irsla wrote:
> Hi,
> 
> On 4/25/07, Matthew Seaman <m.seaman at 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-----


More information about the freebsd-questions mailing list