Search in this blog

Wednesday, March 22, 2017

How to get IP address of specified interface in bash scripting?

There is a one-line pipeline of commands to get IP address assigned to a specified interface. For example to eth0:
ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'

No comments:

Post a Comment