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 am working on a Ruby on Rails project so I have to manage multiple files. I think I made a syntax mistake somewhere but I'm not sure well. It would be awesome if I could search for a keyword through the entire project directory.

I'm sure there's some command on Terminal, but I'm not sure what it is.

share|improve this question
did you want to find the files which contain a specific keyword? – Avinash Raj Jun 23 '14 at 3:43
up vote 0 down vote accepted

You can use the recursive mode of grep:

grep -R pattern directory

ack (ack-grep on Ubuntu) and ag are also good for this.

share|improve this answer
+1 but ack? You mean ack-grep? And what is ag? Did you mean agrep? – terdon Jun 23 '14 at 8:19
I think it should be option -r (--recursive) instead of -R (--dereference-recursive), as -R would follow symlinks out of the project directory. – Volker Siegel Apr 16 at 0:54
cd ~/path/to/your/directory
grep -rwI KeywordCaseSensitive *


-r search recursively
w search for a word only (i.e. surrounded by white space and/or punctuation)
I ignore binary files

You may consider option -i (ignore 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.