1 |
On 2009-07-01, Peter Humphrey <peter@××××××××××××××.org> wrote: |
2 |
|
3 |
> Can anyone explain this to me? |
4 |
> |
5 |
> $ /bin/grep -r hmenu *html |
6 |
> index.html: <div id="hmenu"> |
7 |
> master.html: <div id="hmenu"> |
8 |
> pictures.html: <div id="hmenu"> |
9 |
|
10 |
The shell expands *html to a list of html files in the current |
11 |
directory. IOW, you explicitly gave grep a list of html files |
12 |
to search. The -r flag does nothing in that case. |
13 |
|
14 |
You appear to want to search all files underneath the current |
15 |
directory who's name matches the shell glob pattern "*html". |
16 |
If that's the case, then what you meant to say was: |
17 |
|
18 |
find . -name '*html' | xargs grep hmenu |
19 |
|
20 |
> $ /bin/grep -r hmenu pages/*html |
21 |
> pages/community.html: <div id="hmenu"> |
22 |
> pages/contacts.html: <div id="hmenu"> |
23 |
> pages/history.html: <div id="hmenu"> |
24 |
> pages/music.html: <div id="hmenu"> |
25 |
> pages/news.html: <div id="hmenu"> |
26 |
> pages/people.html: <div id="hmenu"> |
27 |
> pages/pictures.html: <div id="hmenu"> |
28 |
> |
29 |
> Grep is clearly disobeying the recursion command. I started noticing this a |
30 |
> few days ago, and it's making maintenance of this directory hard work. |
31 |
|
32 |
Again, you gave grep an explicit list of files to search, so |
33 |
the -r option doesn't do anything. In this case, it's not |
34 |
obvious what you intend, so I'll refrain from guessing. |
35 |
|
36 |
-- |
37 |
Grant Edwards grante Yow! I want to kill |
38 |
at everyone here with a cute |
39 |
visi.com colorful Hydrogen Bomb!! |