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

Re: Changing permission in user's home directory

On 12/20/2014 at 09:16 PM, Bob Proulx wrote:

> 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.

You're right. I just searched the man page for mentions of symlinks, to
remind myself of what the option was, and didn't read the details as
closely as I should have.

>> ... -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.

Yes, that makes sense in this case. I'm not in the habit of doing it in
most cases, however, because I commonly-enough need to use find with
commands of the form 'command option {} option +' rather than the form
'command option {} +'.

Since find can't tell what significance the additional option(s) after
the argument list would have (i.e. whether to repeat them after each
item in the argument list, or just append them once at the end), it
naturally rejects that syntax as ambiguous.

(The man page indicates that the -exec and -execdir options build their
command lines in much the same way as xargs does, and it's possible to
build the more complicated command lines I need using 'xargs -I', but if
there's a similar syntax or functionality for find I haven't found it.)

That's not to say you aren't right in suggesting that that syntax is the
better approach in this case, just to explain why I didn't think to
suggest it myself, and to point out its limitations for other people who
may read this.

   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

Attachment: signature.asc
Description: OpenPGP digital signature

Reply to: