Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 at 3:43

2 Answers 2

up vote 1 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 at 8:19
cd ~/path/to/your/directory
grep -rwI KeywordCaseSensitive *

Explanateion:

-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

 
discard

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.