-   Linux - Newbie (
-   -   -r parameter not working in grep (

learnfast 03-11-2005 03: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"
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 04:17 AM


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 11:13 AM.