LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash command: grep (https://www.linuxquestions.org/questions/programming-9/bash-command-grep-256199/)

mAineAc 11-17-2004 07:37 PM

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?

itsme86 11-17-2004 07:54 PM

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.

mAineAc 11-17-2004 08:03 PM

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?

Tinkster 11-17-2004 09:15 PM

find -type f -exec grep "text" {} \;


Cheers,
Tink

mAineAc 11-17-2004 09:30 PM

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.

mAineAc 11-17-2004 09:43 PM

ok i got it. I did:
find -type f -exec grep -H "text" {} \;

Tinkster 11-18-2004 11:00 AM

If you only need the name use
Code:

grep -l
instead of -H


Cheers,
Tink


All times are GMT -5. The time now is 02:04 AM.