Created
March 1, 2017 17:37
-
-
Save khalidx/9e945e6b5fb6aac3b7dc7ffa75144cc2 to your computer and use it in GitHub Desktop.
Ubuntu: Get only the IP address of a network interface
This file contains 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
#!/bin/bash | |
# Syntax: ifconfig <interface-name> | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1 | |
# Example: Get the IP address of the eth0 network interface | |
ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment