Skip to content

Instantly share code, notes, and snippets.

Last active March 3, 2020 13:54
  • Star 15 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bzerangue/4393408 to your computer and use it in GitHub Desktop.
A small shell script that will add and remove lines from the hosts file. Originally created by Claus Witt,
#! /bin/sh
# @author: Claus Witt
# Adding or Removing Items to hosts file
# Use -h flag for help
case "$1" in
echo "$IP $2" >> /etc/hosts
sed -ie "\|^$IP $2\$|d" /etc/hosts
echo "Usage: "
echo " [add|remove] [hostname] [ip]"
echo "Ip defaults to"
echo "Examples:"
echo " add"
echo " remove"
exit 1
exit 0
Copy link

Do you have an example of reading from a file and updating hosts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment