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

Re: Changing permission in user's home directory



The Wanderer wrote:
> 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 {} +'.

Yep.  That would push you into using the ; form instead of the + form.

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

A lot of commands have been modified specifically to work with find
and other ways of generating files in this way.  For example the mv
and cp commands have the -t, --target-directory=DIRECTORY option.
That way one can specify things like this.

  find $path -selectionoptions -execdir cp --target-dir=/SOME/PATH {} +

And then all of the options are up front and all of the files are at
the rear.

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

There are some clever hacks to do it in find but I think the xargs way
is better and cleaner so I won't recommend the find workarounds.

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

It was definitely lower down on the list.  And after doing some
testing with -execdir with various cases I am not convinced that the +
form actually does anything different from the ; form.  It appears to
be a current deficiency.  Possibly a current bug.  So this is
definitely small and probably doesn't matter.  At least not now.  But
possibly also a future capability that would be nice to take advantage
of at some point.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: