LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-08-2006, 12:18 AM   #1
arcow
Member
 
Registered: Jan 2006
Distribution: RedHat linux 9
Posts: 31

Rep: Reputation: 15
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?
 
Old 02-08-2006, 03:17 AM   #2
heema
Senior Member
 
Registered: Sep 2003
Location: Egypt
Distribution: Arch
Posts: 1,528

Rep: Reputation: 47
grep -R "search keyword" /home/files
 
Old 02-08-2006, 10:00 AM   #3
ilazarte
LQ Newbie
 
Registered: Feb 2006
Posts: 3

Rep: Reputation: 0
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to clear a file's content? iclinux Linux - Newbie 7 03-30-2009 02:01 PM
Shell script: substitute a file's content according to a map? Chowroc Programming 11 11-15-2005 04:08 AM
Possible to search by content of package not downloaded yet? davidas Debian 4 04-09-2004 03:28 AM
How to modify a file's attribute in shell? Xiangbuilder Linux - Newbie 1 09-06-2003 06:18 AM
Search for a file using shell script sharathkv Linux - Newbie 2 08-06-2003 05:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration