Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 attempted find -name 'a*' 'z*' '*a' '*z'

but it gave me the error code find: paths must precede expression: z*

I know how to find files starting with a though z, or ending with a-z, but not starting with specific letters.

share|improve this question
The error is because you can't combine multiple criteria this way. To specify that you want -name to be either a* or z*, you should say: -name 'a*' -o -name 'z*'. Of course 1_CR gave you the correct answer for your particular case. – Joseph R. Oct 8 '13 at 0:57
up vote 11 down vote accepted

Assuming I understood your question, you are possibly overcomplicating it. This should do

find your_directory -type f -name '[az]*[az]'

This omits files whose name is a single letter a or z. If you also want to include them, you need to specify another pattern: the name must match either [az]*[az] or [az].

find your_directory -type f \( -name '[az]*[az]' -o -name '[az]' \)
share|improve this answer
@Gilles, thank you for addressing the corner case – iruvar Oct 8 '13 at 1:14
find . '(' -name 'a*' -o -name 'z*' ')' -a '(' -name '*a' -o -name '*z' ')' is more similar to what @linux8807 was originally trying to express, and it also catches the corner case. – Matt Oct 8 '13 at 1:21
Or find -name '[az]*' -a -name '*[az]' – frostschutz Oct 8 '13 at 1:42
Wouldn't find -name '[az]*' find files starting with az? That's how I interpreted that. – linux8807 Oct 8 '13 at 19:35
@linux8807, have you tried find -name '[az]*[az]' – iruvar Oct 9 '13 at 18:26

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.