Peter Humphrey a écrit :
Hello list,
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">
$ /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.
As other have pointed out, the behaviour of grep is correct in the
examples above.
You could use the --include directive :
grep -r --include=*html hmenu .
Basically, this tells grep to recursive look for hmenu in any files that
include *html starting from the current directory (* would be equally
fine if you didn't want to search in 'hidden' dot directories).
Regards,
Carlos