nanog mailing list archives

RE: interger to I P address


From: "Darden, Patrick S." <darden () armc org>
Date: Wed, 27 Aug 2008 13:31:50 -0400


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 () ns sol net]
Sent: Wednesday, August 27, 2008 1:29 PM
To: chartley () oar net
Cc: nanog () 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(*).


Current thread: