Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I find a file by its content on Linux in the command line?

For example, I want to find a file containing the word "helo" on my computer.

share|improve this question
2  
Please do some research before posting. –  Praveen Sripati Sep 21 '11 at 11:54
add comment

migrated from serverfault.com Sep 21 '11 at 11:03

This question came from our site for professional system and network administrators.

4 Answers

Use:

grep -lir "helo" /path/to/dir
share|improve this answer
add comment

You can create a file named grepall in /usr/local/bin/ with following content:

find -type f -exec grep -q $1 {} \; -print

then you can search for content by use grepall something

share|improve this answer
1  
That's a lot of typing when you can just grep -r –  Matt H Sep 21 '11 at 12:05
    
With the Command find you can grep recursive through directories and grep in all files. –  kockiren Sep 22 '11 at 7:28
add comment

egrep -R "hello" /path/to/dir

share|improve this answer
add comment

Evil way: grep "something" */*/*

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.