Wednesday, 15 June 2011

bash - Grep only Domain name in HTML -



bash - Grep only Domain name in HTML -

i have html file want domain name's extracted from.

www.this_i_dont_want.com <div class="message" garbage.. garbage... www.hotmail.com hotmail.com hotmail.com/blah.php http://www.hotmail.com/a.php?fdas www. hotmail. com/a.php hotmail . com garbage.... </div>

i want "hotmail.com" extracted example. help appreciated.

this match 3 hotmail.com string. behind used here,

grep -op '(?<=www\.)\s?[^\/]*' file

example:

$ grep -op '(?<=www\.)\s?[^\/]*' file hotmail.com hotmail.com hotmail. com

or

this matches character before .com 0 or more times upto literal dot appears on input,

$ grep -op '[^\.]*\.com' file hotmail.com hotmail.com hotmail.com hotmail.com

i think command looking because matches hotmail.com. no spaces before or after string hotmail.com

bash sed grep

No comments:

Post a Comment