Re: chmod -R +x for directories only
- From: Buzzbomb <buzzbomb@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 30 Aug 2005 18:03:11 GMT
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. .
- References:
- chmod -R +x for directories only
- From: billy
- Re: chmod -R +x for directories only
- From: billy
- Re: chmod -R +x for directories only
- From: Keith Matthews
- Re: chmod -R +x for directories only
- From: Buzzbomb
- Re: chmod -R +x for directories only
- From: Bruce Stephens
- chmod -R +x for directories only
- Prev by Date: Re: Throttling network interface traffic
- Next by Date: Re: chmod -R +x for directories only
- Previous by thread: Re: chmod -R +x for directories only
- Next by thread: Re: chmod -R +x for directories only
- Index(es):
Relevant Pages
|