up vote 1 down vote favorite
1
share [g+] share [fb]

Does "chmod 777 .* -R" chmod parent directories (..) recursively?

link|improve this question

50% accept rate
-> serverfault? – elcuco Jan 3 '10 at 21:10
1  
Not sure what your intended result is. If you want to chmod everything from the current directory and down, the chmod -R 777 ., if you want to only . prefixed directories via find . -maxdepth 1 -type d -name '.*' this would still include ., also the .* expands based upon your $SHELL, not all shells will expand .* to . and ... – Darren Hall Jan 3 '10 at 21:21
feedback

migrated from stackoverflow.com Jan 3 '10 at 21:13

This question came from our site for professional and enthusiast programmers.

3 Answers

up vote 9 down vote accepted

Yes. (Learned it the hard way.)

link|improve this answer
Didn't wait too long for an answer there, did you? :) – jensgram Jan 3 '10 at 21:07
nice to learn! . – elcuco Jan 3 '10 at 21:09
OUCH! (padding) – R. Martinho Fernandes Jan 3 '10 at 21:11
2  
You can echo .*, if .. is included in the output, it's probably not the result you're looking for. – Darren Hall Jan 3 '10 at 21:29
This is true of anything that uses .* - rm -rf .* is particularly nasty. – James Polley Jan 3 '10 at 22:26
show 1 more comment
feedback

yes.

The use of a recursive option(-r) with a wildcard(*) is almost always a bad idea.

if you were trying this:

user@box path/$ foo -r .*

which probably means you also did this first, before realizing it missed hidden files:

user@box path/$ foo -r *

most likely what you wanted to do is

user@box path/$ cd ..
user@box $ foo -r path/

furthermore, chmod 777 is always a bad idea.

link|improve this answer
nice explanation of the problem and a good alternate way of thinking about it that leads to a real solution. – quack quixote Jan 3 '10 at 22:02
Usually these is no need to cd .. && foo -r prevdirname. foo -r . would usually do the same. – Chris Johnsen Jan 3 '10 at 22:17
1  
ah, that brings us to another quirk of mine. I never. ever. ever. ever. run something like that, unless it is something harmless like grep. running a command like 'chown foo -r .' in the wrong directory can be disastrous. Going one directory up and typing the name of the directory you really mean to change forces you to pay more attention to what you are doing. – user23307 Jan 4 '10 at 5:25
@justin: that's the alternate behavior i like. i use foo -r . all the time but i'm very very careful with it. it's still far too easy to forget to check things closely. getting into a habit & attitude of "no -r . ever" is one way to deal with the issue. – quack quixote Jan 4 '10 at 6:44
feedback

Use .??* instead.

link|improve this answer
You also need .[^.] if you want to catch entries like .a. – Chris Johnsen Jan 3 '10 at 22:06
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.