Re: chmod -R +x for directories only



Bruce Stephens wrote:
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.

I was attempting to explain why the exmaple used gave the errors it did, which are due to the interpretation of whitespace by the shell, and provide an example of an alternative which would not suffer from the sames issues *not* enumerate the 93,000 different possible ways the task could be acheived.


B.
.



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: chmod hidden files
    ... If you do chmod -R 777 you mark ALL files as programs, and risk the reputation linux has as a secure OS, and you will get into problems you later blame linux for. ... a vfat partition with noexec option and an umask you prefer. ... Your shell also expand what you type on the command line, ... do as a replacement of a bad command that will give you more problems then you had before. ...
    (alt.os.linux)
  • Re: All files in TERMINAL
    ... > what the -i switch is supposed to do, ... attempt even if chmod had a clue about it since the ... wildcard is expanded by the shell, ... expanding wildcards. ...
    (comp.sys.mac.system)
  • Re: chmod -R +x for directories only
    ... > Its not the find thats the problem, its the whitespace in the ... > results returned which is then being interpreted as field separators ... > without going through the shell. ...
    (uk.comp.os.linux)
  • Re: Linux file system is unstable
    ... >> And without details noone will be able to help you. ... > What difference will it make what the xprogram actually is? ... Leave the interpretation to us. ... Results now depend on whether your shell hashes and caches or not. ...
    (comp.os.linux.misc)