Skip to content

Instantly share code, notes, and snippets.

@iegik
Created November 11, 2013 08:25
Show Gist options
  • Select an option

  • Save iegik/7409710 to your computer and use it in GitHub Desktop.

Select an option

Save iegik/7409710 to your computer and use it in GitHub Desktop.
Update /etc/hosts file, for edding virtualhosts in ~/public_html
#!/bin/bash
HOSTS='/etc/hosts';
TMP='hosts'
cat $HOSTS | grep -vE '127' > $TMP
ls -d1 */ | awk '{ ORS=" "; print; }' | sed "s/\///g;s/^/127.0.0.1 localhost `hostname` /g" >> $TMP
sudo mv $TMP $HOSTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment