On 2009-07-01, Peter Humphrey <pe...@humphrey.ukfsn.org> wrote: > Can anyone explain this to me? > > $ /bin/grep -r hmenu *html > index.html: <div id="hmenu"> > master.html: <div id="hmenu"> > pictures.html: <div id="hmenu">
The shell expands *html to a list of html files in the current directory. IOW, you explicitly gave grep a list of html files to search. The -r flag does nothing in that case. You appear to want to search all files underneath the current directory who's name matches the shell glob pattern "*html". If that's the case, then what you meant to say was: find . -name '*html' | xargs grep hmenu > $ /bin/grep -r hmenu pages/*html > pages/community.html: <div id="hmenu"> > pages/contacts.html: <div id="hmenu"> > pages/history.html: <div id="hmenu"> > pages/music.html: <div id="hmenu"> > pages/news.html: <div id="hmenu"> > pages/people.html: <div id="hmenu"> > pages/pictures.html: <div id="hmenu"> > > Grep is clearly disobeying the recursion command. I started noticing this a > few days ago, and it's making maintenance of this directory hard work. Again, you gave grep an explicit list of files to search, so the -r option doesn't do anything. In this case, it's not obvious what you intend, so I'll refrain from guessing. -- Grant Edwards grante Yow! I want to kill at everyone here with a cute visi.com colorful Hydrogen Bomb!!