lkml.org 
[lkml]   [1998]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: OFFTOPIC: Re: hardlinks.... sucks... ;-(
From
Date
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.

\
 
 \ /
  Last update: 2005-03-22 13:41    [W:0.039 / U:4.896 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site