North American Network Operators Group

Date Prev | Date Next | Date Index | Thread Index | Author Index | Historical

RE: interger to I P address

  • From: Darden, Patrick S.
  • Date: Wed Aug 27 13:32:04 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:[email protected]]
Sent: Wednesday, August 27, 2008 1:29 PM
To: [email protected]
Cc: [email protected]
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(*).