Messages in this thread | | | Subject | Re: OFFTOPIC: Re: hardlinks.... sucks... ;-( | From | "Michael O'Reilly" <> | Date | 07 Jan 1998 15:59:24 +0800 |
| |
Mitch Davis <mjd#NOSPAM@nsmd.aus.hp.com> writes: > Albert D. Cahalan wrote: > > > > > Try something a bit like one of the following: > > > > > > find / -user 1234 -print | xargs chown 4321 > > > find / -user 1234 -print | xargs rm > > > find / -user 1234 -exec chown 4321 {} ; > > > find / -user 1234 -exec rm {} ; > > > > It seems a file starting with "-" could cause trouble too. > > Maybe a name like "--follow-symlinks" would be interesting. > > A file containing a space causes xargs to perform in an often- > unexpected manner. When in doubt, -exec is the (slower but surer) way > to go.
This doesn't really belong here, but the faster, safe way is...
find / -user 1234 -print | perl -nle 'chown 4321, 123, $_'
which only spawns two processes, and doesn't get confused at all about spaces or '-'s in filenames. Still isn't safe from race conditions, but that's a different kettle of fish.
Michael.
| |