-   Linux - Software (
-   -   how to search file's content with shell? (

arcow 02-08-2006 01: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 04:17 AM

grep -R "search keyword" /home/files

ilazarte 02-08-2006 11: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 02:41 PM.