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