Re: chmod -R +x for directories only



Buzzbomb <buzzbomb@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:

[...]

> Its not the find thats the problem, its the whitespace in the
> results returned which is then being interpreted as field separators
> by the shell.

Well, that is the problem with find, or rather xargs (which doesn't
seem to have a way to separate arguments by newline, which seems odd;
that seems like a useful kind of option to have). Hence the GNU
extensions of -print0 and -0.

> a command line like
>
> # find . -type d -exec chmod 711 {} \;
>
> will work fine as the results of the find are passed directly to chmod
> without going through the shell.

Yep, that'll do. Or, in zsh:

chmod 711 **/*(/)

or

for i in **/*(/)
chmod 711 $i

or

for i in ${(f)"$(find . -type d)"}
chmod 711 $i

or, if you have a file produced by "find . -type d > directories" you can do things
like

chmod 711 ${(f)"$(<directories)"}

Probably "find . -type d -print0 | xargs -0 ..." is easiest to
remember, though.
.



Relevant Pages

  • Re: chmod -R +x for directories only
    ... >> results returned which is then being interpreted as field separators ... When the problem is the shell's interpretation of whitespace then the ... problem can be overcome by using the FS variable in the shell. ...
    (uk.comp.os.linux)
  • Re: Passing an argument to a subprocess?
    ... any way I can also pass an argument to the subprocess I'm opening to ... permute_examples program (or shell script). ... A safer quoting mechanism is list quoting, ... never contain whitespace then either is fine. ...
    (comp.lang.tcl)
  • Re: help me out with subroutines
    ... It's also worth mentioning that *echo* isn't trimming the whitespace ... The *shell* tokenizes the command line on whitespace, ...
    (comp.unix.questions)
  • Re: Daemon Starten im Script und wieder beenden
    ... > whitespace am Ende enthalten ist, ... > Whitespace auch in der Variable IFS der shell enthalten ist. ... Prev by Date: ... Next by Date: ...
    (de.comp.os.unix.shell)
  • Re: chmod -R +x for directories only
    ... > When the problem is the shell's interpretation of whitespace then the ... > problem can be overcome by using the FS variable in the shell. ...
    (uk.comp.os.linux)