Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
How do I find text within a file and have it search multiple subfolders?

I would like to find out all the files under mydir/ directory whose content contains the string "apple". How can I do this?

share|improve this question

marked as duplicate by Gilles, Michael Mrozek Nov 16 '11 at 22:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
This has been covered before. Have you performed a search before asking? –  enzotib Nov 16 '11 at 10:28
    
Yes, I tried "gerp "apple"" but it search for all the files in my Ubuntu system which takes a long time. –  Mellon Nov 16 '11 at 10:29
add comment

2 Answers

up vote 1 down vote accepted

Maybe one of those

cd mydir ; grep -lr apple *

or

find mydir -type f | xargs grep -l apple
share|improve this answer
    
What does * starnd for in command "grep -lr apple * "? –  Mellon Nov 16 '11 at 10:41
    
* is target of grep command. It will expand to every name in current folder. –  bbaja42 Nov 16 '11 at 13:41
add comment

There is no need to use find actually, grep can do all that stuff.

grep --recursive --ignore-case --files-with-matches "apple" mydir/
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.