chmod -R doesn't seem to work
Binary package hint: coreutils
Description: Ubuntu 8.10
Release: 8.10
coreutils:
Installed: 6.10-6ubuntu1
Candidate: 6.10-6ubuntu1
Version table:
*** 6.10-6ubuntu1 0
400 http://
500 http://
100 /var/lib/
Expect chmod -R to change mode in subdirectories.
chmod -R 644 *.php should change .php files in this dir and subdirs.
Does not change mode in subdirectories.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Ubuntu coreutils Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Lars Ljung
- Solved:
- 2009-03-09
- Last query:
- 2009-03-09
- Last reply:
- 2009-03-09
This question was originally filed as bug #339777.
Chris Coulson (chrisccoulson) said : | #1 |
chmod -R works fine for me. It is very unlikely that there is a bug here, so I'm going to convert this in to a support request in the answer tracker.
|
#2 |
I think you have misunderstood how the shell works. The so called glob pattern *.php is first expanded to something like "file1.php file2.php" and then chmod is called as "chmod -R file1.php file2.php". So chmod is not told to operate on any directories (unless you have directories matching the pattern of course, like dir1.php).
To do what you want to do you will have to use find, like this:
find . -name "*.php" -exec chmod 644 \{\} \;
This will search for any files that matches the specified pattern, starting in the current directory (".") and then execute the command chmod on each file (\{\} is replaced with the filename).
Micah Gersten (micahg) said : | #3 |
For some reason, I thought it worked differently...not quite sure why.
Micah Gersten (micahg) said : | #4 |
Thanks Lars Ljung, that solved my question.