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
find . -name *.rb

doesn't work on my ubuntu

I have to do

find . -name "*.rb"

to get it to work.

Why is that?

share|improve this question
I cannot say why, but it is the same on Solaris UNIX (when the * is used). I have had to do it that way for many years. – Tim Mar 13 '12 at 21:48
might consult man find – Ringtail Mar 13 '12 at 22:19
up vote 11 down vote accepted

If you have a file in the current directory ending with .rb, it'll be expanded by the shell. So, if you have one file named "foo.rb", the command that gets executed is find . -name foo.rb. ("find a file named foo.rb")

It gets even worse if you've multiple files in the current directory (say, "foo.rb" and "bar.rb"). Then the command becomes find . -name foo.rb bar.rb, which will cause an argument error for find.

To prevent the shell from expaning the glob pattern *.rb, you must either quote it (either single or double quotes will do) or escape the asterisk. The below commands have equivalent behavior:

find . -name "*.rb"
find . -name '*.rb'
find . -name \*.rb
share|improve this answer

Wildcards, Quotes, Back Quotes and Apostrophes in shell commands ( * ? [] " ` ') I goggled it lol

share|improve this answer
You can try man bash and then /QUOTING (the slash starts a search) and read it up in the manpage as well. – user unknown Apr 14 '12 at 23:03

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.