Skip to content

Instantly share code, notes, and snippets.

@bitnot
Created September 13, 2018 07:08
Show Gist options
  • Save bitnot/5b83be88e5125ea58eddf9062b74b14e to your computer and use it in GitHub Desktop.
Save bitnot/5b83be88e5125ea58eddf9062b74b14e to your computer and use it in GitHub Desktop.
Gets first IP address of your network interface(s)
MYIP=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n 1`
echo $MYIP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment