Created
June 25, 2015 11:21
-
-
Save lsongdev/956a8310782caf469a06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # put your hosts file into /etc/hosts.d/ | |
| # | |
| # usage: | |
| # chhost $your-host-name | |
| # restore: | |
| # chhost | |
| HOSTD=/etc/hosts.d | |
| SRC="$HOSTD/$1" | |
| DEST="/etc/hosts" | |
| sudo mkdir -p $HOSTD | |
| if [ -z $1 ]; then | |
| sudo mv $DEST{.bak,} | |
| else | |
| sudo mv $DEST{,.bak} | |
| sudo cp $SRC $DEST | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment