5
2
Does chmod 777 .* -R
change the mode of parent directories (..) recursively?
5
2
Does chmod 777 .* -R
change the mode of parent directories (..) recursively?
12
Yes. (Learned it the hard way.)
2Didn't wait too long for an answer there, did you? :) – jensgram – 2010-01-03T21:07:18.550
nice to learn! . – elcuco – 2010-01-03T21:09:27.017
OUCH! (padding) – R. Martinho Fernandes – 2010-01-03T21:11:44.593
2You can echo .*
, if ..
is included in the output, it's probably not the result you're looking for. – Darren Hall – 2010-01-03T21:29:56.020
This is true of anything that uses .* - rm -rf .*
is particularly nasty. – James Polley – 2010-01-03T22:26:38.183
@jensgram Yep :D Actually, I wanted to put it out there for other newbies so they don't repeat my mistake. – Olivier Lalonde – 2010-01-04T03:41:08.800
8
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.
1nice explanation of the problem and a good alternate way of thinking about it that leads to a real solution. – quack quixote – 2010-01-03T22:02:36.140
Usually these is no need to cd .. && foo -r prevdirname
. foo -r .
would usually do the same. – Chris Johnsen – 2010-01-03T22:17:35.237
1ah, 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 – 2010-01-04T05:25:25.780
@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 – 2010-01-04T06:44:48.913
5
Use .??* instead.
2You also need .[^.] if you want to catch entries like .a
. – Chris Johnsen – 2010-01-03T22:06:46.023
0
Use zsh (which does not match . or .. in ANY glob), or use .[^.]* .??* to match all hidden files. The first part of the glob matches any file that begins with a dot and has as its next character something other than a dot, thus avoiding . and .. The second part matches any file that starts with a dot and is at least three characters long.
To match all files other than . and .. hardlinks, use * .[^.]* .??* , or (on Z shell ONLY) . .*
-> serverfault? – elcuco – 2010-01-03T21:10:07.420
1Not 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 viafind . -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 – 2010-01-03T21:21:42.370