OS: XP Home Edition
I regularly download an updated HOSTS file (hosts.zip)
from http://www.mvps.org/winhelp2002/hosts.htm. This
HOSTS file is intended to be a security precaution,
redirecting suspect sites to 127.0.0.1 (localhost). It
contains lots of comments, (# symbol).
Question: Would someone please suggest an efficient
method for stripping the comments from the HOSTS file,
i.e, reducing the HOSTS file to a two column format of
the form: 127.0.0.1 blockthissite.com
In the past, I've used Cygwin's UNIX emulation to
accomplish the task, but at ~150 MB disk space, that's a
bit too pricey.
I have UnxUtils, but there are two problems: (1) DOS
batch files calling the UnxUtils' .exe's require a screwy
syntax that isn't documented, requiring a trial-and-error
approach, and (2) I cannot figure out how to write a zsh
shell script and make it execute in XP.
Ideally, I'd like a "program" that:
0. Can be accessed from the Start Menu
1. Checks http://www.mvps.org/winhelp2002/hosts.htm for
an updated HOSTS file (hosts.zip)
2. Downloads and unpacks hosts.zip
3. Strips HOSTS of comments
4. First line must be 127.0.0.1 localhost
5. Subsequent lines unique and sorted alphabetically
6. Replaces & assigns any pre-existing HOSTS file read-
only permission (chmod 444)in XP's drivers\etc directory
7. Deletes any temporary files created interim
Step (1) might be tough: I'm willing to do this manually.