1

I'm searching some files with: find . -name "*.en.php" and find . -name "*.fr.php".

I want both commands in the same line, something like : find . -name "*.(en|fr).php" but it doesn't work.

Thanks in advance for your help.

EDIT

my command is like this : find . -not -path Config -name "*.fr.php", is there a solution do not repeat -not -path Config ?

3 Answers 3

3

Try:

find -name "*.en.php" -o -name "*.fr.php"

If you for example want to run command on each found file, than you need to additional () (this will count num of lines in all found files):

find \( -name "*.en.php" -o . -name "*.fr.php" \) -exec cat {} \; | wc -l
Sign up to request clarification or add additional context in comments.

Comments

0

You should be able to combine expression with an or operator, thus:

find . -name '*.en.php' -o -name '*.fr.php' ...

You can see all the operators in the man page listed under OPERATORS (and, or, not, parentheses and so forth).

Comments

0

Use the find -o operator, eg.

find . -name "*.en.php" -o -name "*.fr.php"

Edit:

Like so:

find . -path './Config' -prune -o \( -name "*.en.php" -o -name "*.fr.php" \)

The default operator in find (if one is ommited) is and, the parentheses group the name expression. I've added -prune to prevent find from recursing into the Config directory.

2 Comments

thanks, but it's not working, i get it with find ./^Config \( -name "*.fr.php" -o -name "*.en.php" \)
@jules: I messed up -path, also note that -path expects a full pathname, perhaps you want to use in conjunction with -prune?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.