LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-05-2005, 06:20 AM   #1
darkpark
LQ Newbie
 
Registered: Nov 2003
Location: NW Indiana
Distribution: Ubuntu 6.06 LTS
Posts: 18

Rep: Reputation: 0
how do i search files for a particular string?


from the console, how do i find a which files contain a particular string? i know that i could easily do it in X easily, but I'd like to learn how to do it from the command prompt.
doesn't it involve using the grep command? i tried reading the man pages for the grep command but i could make any heads or tails on how do search all files in a directory tree.
so could someone give me some examples?

thank you.
 
Old 07-05-2005, 06:49 AM   #2
munkie_poo
Member
 
Registered: Apr 2004
Location: Newcastle, UK
Distribution: Slackware 10.2
Posts: 134

Rep: Reputation: 15
This is how to find a sting in a particular text file

less textfile | grep "string "
 
Old 07-05-2005, 06:53 AM   #3
priller
Member
 
Registered: Jan 2004
Distribution: Debian etch
Posts: 202

Rep: Reputation: 30
or if you want to search a directory

Code:
grep string -r path
 
Old 07-05-2005, 06:55 AM   #4
singhalyogesh
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Rep: Reputation: 0
Hi,
You can use the grep command to find all the files having a partcular string. The syntax for the same is as follows

grep " search string" -r path

it will list all the files having the search string

Cheers

Last edited by singhalyogesh; 07-05-2005 at 06:57 AM.
 
Old 07-05-2005, 05:46 PM   #5
darkpark
LQ Newbie
 
Registered: Nov 2003
Location: NW Indiana
Distribution: Ubuntu 6.06 LTS
Posts: 18

Original Poster
Rep: Reputation: 0
thank you very much.
 
  


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
Is it possible to search for a string from all the files on the harddisk? Akhran Linux - Newbie 8 09-13-2005 06:09 AM
search for a string in c alaios Programming 1 07-07-2005 04:50 PM
C....Search a string for a string Scrag Programming 4 06-14-2004 04:15 PM
[c++] Search in a string hylke Programming 5 06-14-2004 11:20 AM
search for my string alaios Linux - General 6 05-08-2004 01:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:12 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