LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   -r parameter not working in grep (http://www.linuxquestions.org/questions/linux-newbie-8/r-parameter-not-working-in-grep-300313/)

learnfast 03-11-2005 04:59 AM

-r parameter not working in grep
 
After reading a number of grep tutorials, I try:

grep -irl '12:00' *.log

which finds all files that end with .log
and contain "12:00"
but ONLY IN THE CURRENT DIRECTORY
I have another directory called "backupLogs" which it doesn't seem to search through

the -r doesn't seem to work

What am I doing wrong?

druuna 03-11-2005 05:17 AM

Hi,

It does not work because of the wildcard (*.log) you are using.

The first thing the shell does is expand the *.log, but does this for the current dir only (we are expanding, grep is not in the picture yet). The result of this is given to the grep command and processed by grep.

This will work (2 commands):

grep -irl '12:00' | grep 'log$'

Or using 'one' command:

find . -name "*log" -exec grep -i '12:00l' {} \;

Hope this helps.


All times are GMT -5. The time now is 07:56 AM.