Pages

Wednesday, July 6, 2011

script to return ip address of an interface

#!/bin/bash
sudo ifconfig ${1-eth1} | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'




--
My Emacs Files At GitHub

1 comment:

  1. Call me old fashioned, but I can't stand the wasted processes

    #!/bin/bash
    sudo ifconfig ${1-eth1} | awk -F'[ :]+' '/inet addr/ {print $4}'

    ReplyDelete