Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I trying to remove boring \-escaping from this command:

find . \( -name '*.mp3' -o -name '*.jpg' \) -print

by wrapping it in single quotes:

find . '( -name *.mp3 -o -name *.jpg )' -print

implying that arguments go straight to the find without any expansions.

However the output is different.

share|improve this question
up vote 4 down vote accepted
find . -name '*.mp3' -o -name '*.jpg' -print
share|improve this answer
It seems the closest way to get rid of \-escaping and make code cleaner. Thanks for sharing! – user52151 Nov 21 '12 at 13:50

You could also use regular expressions, which in my opinion make this more concise and gives you better control:

find . -regextype posix-egrep -iregex '.*(pdf|mp3)$'

This finds all files (or directories, unless you specify -type f) that end in pdf or mp3.

share|improve this answer
find . '( -name *.mp3 -o -name *.jpg )' -print

This looks for all files in the directories named . and ( -name *.mp3 -o -name *.jpg ), which is probably not what you intended.

Use the single quotes just for the round brackets:

find . '(' -name '*.mp3' -o -name '*.jpg' ')' -print
share|improve this answer
Thanks for reply! Is it possible to move a little bit further with it and remove that cumbersome escapings? Ideally to have as little quotes as possible? – user52151 Nov 21 '12 at 13:40

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.