One-liner to Get IP Address of Interface

One-liner to Get IP Address of Interface

The following command is enough for extract IP address from ifconfig command. It uses field separator ":" and " " (space) to cut the line into words.

ifconfig eth0 | grep 'inet addr' | awk -F'[: ]+' '{ print $4 }'