LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   how to search file's content with shell? (http://www.linuxquestions.org/questions/linux-software-2/how-to-search-files-content-with-shell-412853/)

arcow 02-08-2006 12:18 AM

how to search file's content with shell?
 
for example:
in the directory : /home/files/
has many files ,such as
1.php 2.php 3.php 4.php
5.php 6.txt 7.c

and i want to search the content of these files,such as 1.php's content is

function abc(){

}

how can i through a keyword "function" to find the file 1.php or more with shell?

heema 02-08-2006 03:17 AM

grep -R "search keyword" /home/files

ilazarte 02-08-2006 10:00 AM

or if your grep isn't recursive enabled,
find . -type f -name "*.php" -print | xargs grep -i "keyword"

file all files in any subdirectory,
starting from this directory,
that are named *.php
inside of which there is a match for keyword, case insensitive.


All times are GMT -5. The time now is 11:25 AM.