View Single Post
Posts: 334 | Thanked: 616 times | Joined on Sep 2010
#12
No, after cutting out the comments behind #-characters you can freely grep away any lines containing anything else than 0.0.0.0.

Code:
cat hosts.txt | grep -v ^# | cut -d "#" -f 1 | grep 0.0.0.0 | grep -v localhost >> /etc/hosts.tmp && cat /etc/hosts.base /etc/hosts.tmp >> /etc/hosts && rm /etc/hosts.tmp && sed 's/^ *//; s/ *$//; /$/d' /etc/hosts
I tested with this hosts.txt:
Code:
0.0.0.0 im.not.malicious
112.112.112.112 im.malicious.com #localhost.localdomain #localhost #127.0.0.1
112.112.112.113 im.malicious.com localhost.localdomain localhost #127.0.0.1
111.111.111.114 colocalhosted #127.0.0.1 #colocalhosted
111.111.111.115 evil.com  #127.0.0.1
# [ZEDO]
0.0.0.0 zedo.com #[WebBug]
0.0.0.0 ads.zedo.com
0.0.0.0 c1.zedo.com
0.0.0.0 c2.zedo.com #[Tracking.Cookie]
0.0.0.0 c3.zedo.com
Which then resulted in as this hosts-file:
Code:
127.0.0.1 localhost localhost.localdomain
::1 localhost6 localhost6.localdomain6
0.0.0.0 im.not.malicious
0.0.0.0 zedo.com 
0.0.0.0 ads.zedo.com
0.0.0.0 c1.zedo.com
0.0.0.0 c2.zedo.com 
0.0.0.0 c3.zedo.com
 

The Following User Says Thank You to Manatus For This Useful Post: