Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a directory with numerous files. Part of the files have the 755 permissions and the other part have 644 permissions. I'd like to convert the files with 755 permissions to 644. I have tried the following line by running it from the directory itself:

find . -perm 755 -exec chmod 644 {}\;

However as a result, the permission changed only for the directory itself and after changing it back I found out that the files permissions remained unchanged. Do I miss something?

share|improve this question
    
Your command removes the executable bit from the directory, making it impossible to chdir to it and look at the files it contains. That's why the command doesn't seem to be working. Try find ./ -type f -exec chmod -x {} \; instead. –  Shadur May 22 '12 at 11:20

1 Answer 1

up vote 4 down vote accepted

Ok, it seems that I've found the problem. It seems that there must be a mandatory space between the {} and \;, so the command will look like this:

find . -perm 755 -exec chmod 644 {} \;

Rather than:

find . -perm 755 -exec chmod 644 {}\;

Also the issue with changing the directory permissions can be solved by adding a -type f flag, so it'll look as follows:

find . -type f -perm 755 -exec chmod 644 {} \;
share|improve this answer
3  
You could use + instead of \; to reduce the number of subprocesses created. –  Kevin May 22 '12 at 14:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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