Md. Minhazul Haque
Minhaz's Blog

Minhaz's Blog

One-liner to Get IP Address of Interface

One-liner to Get IP Address of Interface

Md. Minhazul Haque's photo
Md. Minhazul Haque
·Feb 23, 2015·

1 min read

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 }'
 
Share this