LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-03-2004, 12:43 AM   #1
kau2
LQ Newbie
 
Registered: Jan 2004
Posts: 14

Rep: Reputation: 0
How do you search for a string?


I want to search for the string blah in all the files in a dir, including files in sub-dirs. I have the command:

find . -exec grep "blah" '{}' \; -print

Only problem is once it goes into the sub-dirs it lists them all. How can I stop this? I just want my search to return the exact files that contain that text.
 
Old 01-03-2004, 12:49 AM   #2
oxblood
Member
 
Registered: Jan 2004
Location: Atlanta, GA
Distribution: Slackware 12.2
Posts: 82

Rep: Reputation: 17
Why don't you just use grep:

grep -R "blah" /path/to/your/dir/*

You may also try your own command like this:

find /path/to/your/dir/ -type f -exec grep "blah" {} \; -print

Last edited by oxblood; 01-03-2004 at 02:08 PM.
 
Old 01-05-2004, 07:51 PM   #3
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Quote:
Originally posted by oxblood
You may also try your own command like this:

find /path/to/your/dir/ -type f -exec grep "blah" {} \; -print
This is EXACTLY the syntax I was looking for! Thanks!

I'm not doing the same task as kau2 but I needed to do something similar to generate MD5 checksums for a TON of files.

Thanks!

Peace....
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
search for a string in c alaios Programming 1 07-07-2005 05:50 PM
C....Search a string for a string Scrag Programming 4 06-14-2004 05:15 PM
[c++] Search in a string hylke Programming 5 06-14-2004 12:20 PM
string search in C h/w Programming 17 10-13-2003 07:26 PM
Search for a string TheOriginalH Linux - General 5 09-24-2003 11:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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