Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

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

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

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

2  
Please do some research before posting. – Praveen Sripati Sep 21 '11 at 11:54

Use:

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

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

share|improve this answer

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

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

share|improve this answer

Your Answer

 
discard

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