Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How come this command:

find . -name \*.css -o -name \*.php -type f

gives me a list of all the *.css and *.php files BUT adding the 'exec' option:

find . -name \*.css -o -name \*.php -type f -exec chmod 664 {} \;

only changes the file permissions of the *.php files and not the *.css ?

NOTE: I am using Amazon EC2 Linux.

share|improve this question
    
thank you for helping me mark up the code text, I am still learning how do properly post questions here –  J. Chin Feb 19 '13 at 17:56

1 Answer 1

up vote 5 down vote accepted

You misunderstand the AND / OR actions.

find . \( -name \*.css -o -name \*.php \) -type f -exec chmod 664 {} \;

find tries to find out whether an expression is true or false. If the left side of an OR is already true then it is not necessary to execute the right side. Your approach would work if OR had higher priority than AND but that is not the case.

share|improve this answer

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.