Click to See Complete Forum and Search --> : help with grep


bolty
02-23-2001, 06:46 AM
I am the webmaster of a university but have little to no experience of searching using GREP. I need to find the name of all web pages in all sub dirs that contain a hyper-link to a now redundant sub-site. If ne1 can help plz email me.

:confused:

jemfinch
02-23-2001, 09:06 AM
find . -name "*.html" | xargs grep redundant_hyperlink

Jeremy

Sterling
02-23-2001, 10:11 AM
Or grep -r "redundant_hyperlink" * in the root directory of the web site, but that's not quite as optimal.

grep -r is very nice, BTW. It does a recursive grep through all the levels of the directory tree below the current one. Unfortunately, I think its not too common - it may only be in the GNU version of grep.

TheLinuxDuck
02-23-2001, 10:48 AM
bolty:

What I use is similar to jemfinch's way, execpt that I use the -exec functionality of find. it's a very nice feature.. and something that I use with grep, also, is -H. It will give you the name of the file that contains the data, as:

find /dir/start -name "*.htm*" -exec grep -H "search_string" '{}' ';'