Skip to content

Instantly share code, notes, and snippets.

View mtthlm's full-sized avatar
🐉

Matt Helm mtthlm

🐉
View GitHub Profile
@mtthlm
mtthlm / hosts.sh
Created February 6, 2014 15:59 — forked from mikeflynn/etchosts.sh
Shell script for managing your /etc/hosts file
#!/bin/bash
HOSTSFILE="/etc/hosts"
BAKFILE="$HOSTSFILE.bak"
DOMAINREGEX="^[a-zA-Z0-9]{1}[a-zA-Z0-9\.\-]+$"
IPREGEX="^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
URLREGEX="^https?:\/\/[a-zA-Z0-9]{1}[a-zA-Z0-9\/\.\-]+$"
backup() {
cat $HOSTSFILE > $BAKFILE