Skip to content

Instantly share code, notes, and snippets.

@Lvl4Sword
Created March 20, 2016 08:05
Show Gist options
  • Save Lvl4Sword/6073bde7c7e901c2495b to your computer and use it in GitHub Desktop.
Save Lvl4Sword/6073bde7c7e901c2495b to your computer and use it in GitHub Desktop.
HOSTS file creation
# this is a fairly basic script that i use to create a sorted HOSTS file
# copy whatever is printed out, and you have a HOSTS file :-)
a = []
b = []
with open('/home/user/hosts.txt', 'r') as infile:
for each in infile:
a.append(each.replace('\n',''))
a = sorted(a)
for each in a:
if each not in b:
b.append('127.0.0.1 ' + each)
for each in b:
print(each)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment