Using ifconfig
FIBER_ADDR=$(ifconfig $FIBER | grep 'inet addr' | sed 's/^[^:]\+://;s/\([^ \t]\+\).\+$/\1/')
echo $FIBER_ADDR
Same using IP command
ip addr show | awk '/inet[^6]/ { print $2 }' | sed -e 's/\(.\+\)\/.\+/\1/'
FIBER_ADDR=$(ifconfig $FIBER | grep 'inet addr' | sed 's/^[^:]\+://;s/\([^ \t]\+\).\+$/\1/')
echo $FIBER_ADDR
Same using IP command
ip addr show | awk '/inet[^6]/ { print $2 }' | sed -e 's/\(.\+\)\/.\+/\1/'
No comments:
Post a Comment