LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 05-07-2004, 02:58 PM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
search for my string


Hi i want to find the command with which i can search for string inside the files...
I was thinkging this
find ./ -name '*mplampla*' | grep mystring
 
Old 05-07-2004, 03:34 PM   #2
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
You can try:

find -exec grep --with-filename 'mystring' {} \;

Lyle
 
Old 05-08-2004, 09:24 AM   #3
dominant
Member
 
Registered: Jan 2004
Posts: 409

Rep: Reputation: 30
Why dont try :

egrep mystring ./
 
Old 05-08-2004, 11:48 AM   #4
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45
find -exec grep --with-filename 'mystring' {} ;
find: missing argument to `-exec'


The second way with egrep doesn't seems to work
 
Old 05-08-2004, 12:57 PM   #5
dominant
Member
 
Registered: Jan 2004
Posts: 409

Rep: Reputation: 30
Re-try

egrep -R mystring ./
 
Old 05-08-2004, 01:34 PM   #6
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
Quote:
Originally posted by alaios
find -exec grep --with-filename 'mystring' {} ;
find: missing argument to `-exec'
Don't forget to put the escape character, that is "\", before the ";".

Like this:

find -name '*mplampla*' -exec grep --with-filename 'mystring' {} \;

dominant is right; if you want to grep through all the files, egrep -R is the way to go. If you only want to search through some of the files, I think find is a good way to go.

Lyle
 
Old 05-08-2004, 02:32 PM   #7
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45
:)

thx guys
 
  


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 08:20 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration