Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Scripts to create an IP info summary display' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Scripts to create an IP info summary display
Authored by: knouse on Sep 02, '06 02:32:06PM
Doing that outputs the netmask in reverse order

Since I don't know Perl I piped the output to sed to reverse the order

get_mask ()
        [ "$1" == "" ] && return
        ifconfig $1 | perl -nase 'print join(".",unpack("CCCC",pack("L*",oct $F[3]))) if (m/mask/);' \
            | sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/\4.\3.\2.\1/'

[ Reply to This | # ]