Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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


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.