[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Changing permission in user's home directory



The Wanderer wrote:
> As usual when dealing with recursive action under *nix, the answer is
> find:

Yes!  :-)

> find -P ...

> The '-P' option tells find to never follow any symlinks.

A small comment upon the technique.  Just noting that -P is the
default.  No need to specify it explicitly.

    -P     Never follow symbolic links.  This is the default behaviour.
           When find examines or prints information a file, and the
           file is a symbolic link, the information used shall be
           taken from the properties of the symbolic link itself.

Just in case someone were to learn about -P and think they needed to
add it to all of their scripts for safety.  They don't.  It is safe
without it.  :-)

Why does -P exist?  Symmetry with -L.  Plus there are some script
techniques where it is convenient to have an explicit way to override
a previous -L by adding a -P after it.  Almost all of the commands
that have a -L (such as 'cd') also have a -P for the same reason.

       If more than one of -H, -L and -P is specified, each overrides
       the others; the last one appearing on the command line takes
       effect.  Since it is the default, the -P option  should  be
       considered to be in effect unless either -H or -L is specified.

> ... -execdir chgrp www-data {} \; ...

I suggest using the "{} +" form since it is more efficient.  And it
has the additional advantage that it doesn't need to be escaped.

       As with the -exec action, the `+' form of -execdir will build a
       command line to process more than one matched file, but any
       given invocation of command will only list files that exist in
       the same subdirectory.

Find is good stuff!

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: