Skip to content

Instantly share code, notes, and snippets.

@thomaslaurenson
Created May 14, 2018 06:05
Show Gist options
  • Save thomaslaurenson/2147a208c40a0031cb8355726b909207 to your computer and use it in GitHub Desktop.
Save thomaslaurenson/2147a208c40a0031cb8355726b909207 to your computer and use it in GitHub Desktop.
# Fetch the NIC name (e.g., eth0, ens33)
NIC=$(ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d')
# Print the IP address of the NIC
ifconfig $NIC | awk '/t addr:/{gsub(/.*:/,"",$2);print$2}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment