[CentOS] Re: manipulating files and directories with spaces

Tony Mountifield tony at softins.clara.co.uk
Wed Nov 21 10:45:12 UTC 2007

In article <20071121102709.GH12494 at br-online.de>,
Ralph Angenendt <ra+centos at br-online.de> wrote:
> William L. Maltby wrote:
> > On Wed, 2007-11-21 at 10:04 +0100, Ralph Angenendt wrote:
> >> Shad L. Lords wrote:
> >>> find . -type type -print0 | xargs -0 chmod value
> >> 
> >> Or (SUSV compliant): 
> >> 
> >> find . -type f -exec chmod 123 {} +
> > 
> > Easier to type and more natural (for me). But less efficient than the
> > xargs version since each file cause a new process to be spawned. For a
> > very large number of items the difference would be noticeable.
> Wrong.
>        -exec command {} +
>               This variant of the -exec option runs the specified command on
>               the selected files, but the command line is built by appending
>               each selected file name at the end; the total number of  invo-
>               cations  of  the  command will be much less than the number of
>               matched files.  The command line is built in much the same way
>               that  xargs  builds  its  command lines.  Only one instance of
>               {} is allowed within the command.  The command  is  executed
>               in the starting directory.
> And yes, that works on mostly any Unix (as said: SUSV compliant), while
> many commercial unixes have "interesting" implementations of xargs and
> -print0 (or don't have that at all).

Maybe, but unless it works on CentOS 5, it is irrelevant to this list.
It certainly is not available in the "find" on CentOS 4:

[root at hostname ~]# find /home/user/ -type f -exec echo {} + \:
find: missing argument to `-exec'
[root at hostname ~]#

Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org

More information about the CentOS mailing list