LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-17-2004, 08:37 PM   #1
mAineAc
Member
 
Registered: Nov 2000
Location: Hermon, ME
Distribution: slackware
Posts: 201

Rep: Reputation: 30
bash command: grep


How long should it take to run this command on say 50 MB of files? I am using the command 'grep "some text" ./* -ras' on a directory that is the root of a damn small linux filesystem I am reworking the iso. It has been running for two days. Is this normal? Is there a faster way to search through that many files to find what contains certain text?
 
Old 11-17-2004, 08:54 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 58
No, it's not normal. How much is grep taking in the way of CPU resources? How much harddrive activity is there? If they're both very very low then I'd guess that grep is waiting for keyboard input.

fgrep is faster than grep if you don't need the use of regular expressions.
 
Old 11-17-2004, 09:03 PM   #3
mAineAc
Member
 
Registered: Nov 2000
Location: Hermon, ME
Distribution: slackware
Posts: 201

Original Poster
Rep: Reputation: 30
doesn't seem to be using anything for resources except it shows it as an active process when i do ps. What kind input? is there somethingwrong with the command i typed? If I don't tell it to ignore the not found files with the -s it does list some /bin files. What would be a better way to find a string of text in that many files?
 
Old 11-17-2004, 10:15 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,000
Blog Entries: 11

Rep: Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893
find -type f -exec grep "text" {} \;


Cheers,
Tink
 
Old 11-17-2004, 10:30 PM   #5
mAineAc
Member
 
Registered: Nov 2000
Location: Hermon, ME
Distribution: slackware
Posts: 201

Original Poster
Rep: Reputation: 30
that gave back the line of text that contained the text but it did not tell me what files it was in. I actually need the file that contains the text. Thank you for the reply.
 
Old 11-17-2004, 10:43 PM   #6
mAineAc
Member
 
Registered: Nov 2000
Location: Hermon, ME
Distribution: slackware
Posts: 201

Original Poster
Rep: Reputation: 30
ok i got it. I did:
find -type f -exec grep -H "text" {} \;
 
Old 11-18-2004, 12:00 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,000
Blog Entries: 11

Rep: Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893
If you only need the name use
Code:
grep -l
instead of -H


Cheers,
Tink
 
  


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
How to grep similar lines in bash? bruno buys Linux - Software 2 12-03-2005 12:56 AM
Bash script question (grep and awk) hamish Linux - Software 6 04-06-2005 04:14 PM
Bash assignment - using a grep inside an if statement lowpro2k3 Programming 4 03-25-2005 06:24 PM
bash script and grep syros Programming 4 01-13-2005 04:04 PM
newbe bash question ( grep processing) therealbxp Programming 2 11-20-2004 08:40 AM


All times are GMT -5. The time now is 06:39 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration