LinuxQuestions.org
Visit Jeremy's Blog.
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 05-12-2009, 01:28 AM   #1
vaibhavs17
Member
 
Registered: Mar 2009
Posts: 51

Rep: Reputation: 1
find utitly for content searching


Hi all,

I want to find particular "pattern" in current directory.
reuslt should display all filenames which contains this pattern.
please help me on this.

using grep, i can search for particular file like that
grep 'pattern' *.cpp

thanks in advance,
vaibhav
 
Old 05-12-2009, 01:43 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Can you explain why grep isn't the tool you want?
 
Old 05-12-2009, 01:48 AM   #3
vaibhavs17
Member
 
Registered: Mar 2009
Posts: 51

Original Poster
Rep: Reputation: 1
I got answer from some other forum.


Originally Posted by brewbuck
To search a single file for an instance of a string "foo":


Code:
grep foo <filename>
To recursively search all files under a particular directory for a string "foo", and display the names of files which contain that string:


Code:
grep -Hrl foo <dir>


this command is really amazing. can you tell me what does -H options with grep.
I could understand the usage of r and l option ... r used for recursive search and l used for display list of file which contains patter foo
 
Old 05-12-2009, 01:58 AM   #4
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
-H prints the filename with matches.

See "man grep" for details of the grep command (or "man command" in general)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Searching for JDK using find mconstant Linux - Newbie 5 11-20-2008 10:08 AM
find content by second ust Linux - Software 1 05-02-2008 05:58 AM
LXer: Searching database content with Sphinx LXer Syndicated Linux News 0 08-24-2007 10:41 PM
Searching text files by content will103 Linux - Software 1 01-24-2005 07:43 AM
searching content of pdf documents bran Linux - Software 3 10-08-2004 07:35 AM

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

All times are GMT -5. The time now is 06:12 PM.

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