Linux : find & grep

Solved
2009 -  
 Gavroche -
Hello,

you need to use the following command with grep and find:
display the names of files that contain the word "premier" starting from your "home" folder.

I tried with: find ~ -name * -print -exec grep "premier"

but I'm only able to display the lines... how can I display the file names?
Configuration: Windows XP Firefox 3.0.1

9 réponses

bob031 Posted messages 8228 Status Membre 473
 
Hello,

this one should work too:

find . -type f -name "*.php" -exec grep -il 'pattern' {} \;


or this one:

find . -name "*.php" -print0 | xargs -0 egrep pattern


^ ^
--
a penguin on the ice floe!
28
Gavroche
 
You're welcome ;)
0