Get only the IP address
# method 1 $ echo $(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') # method 2 $ echo $(ip -o -4 addr list eth0 | perl -n -e 'if (m{inet\s([\d\.]+)\/\d+\s}xms) { print $1 }')