interger to I P address

Darden, Patrick S. darden at armc.org
Wed Aug 27 12:31:50 CDT 2008


Somebody's going to bring in Emacs now.  Then somebody else will claim VI can do it faster and using less memory....

Argh.  ;-)
--p

-----Original Message-----
From: Joe Greco [mailto:jgreco at ns.sol.net]
Sent: Wednesday, August 27, 2008 1:29 PM
To: chartley at oar.net
Cc: nanog at nanog.org
Subject: Re: interger to I P address


> bash# iptoint(){ oct1=`echo $1|awk -F\. '{print $1}'`; oct2=`echo $1|awk -F\. '{print $2}'`; oct3=`echo $1|awk -F\. '{print $3}'`; oct4=`echo $1|awk -F\. '{print $4}'`; echo $[($oct1<<24)+($oct2<<16 )+($oct3<<8)+$oct4 ];}
> bash# inttoip(){ echo $[$1>>24].$[($1>>16)&255].$[($1>>8)&255].$[$1&255]; }
> 
> bash# inttoip 1089055123
> 64.233.169.147

BASH?  Hahaha.  Real Admins use sh.  More portable(*).




More information about the NANOG mailing list