interger to I P address

Sorry to be continuing this thread, but I find a certain kind of elegance in
bash which isn't actually there, but helps me sleep at night.

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# iptoint 64.233.169.147
1089055123

Chris

siza # ping -c 1 1089055123 | head -n 1 | awk '{{{print $3}}}' | sed 's/(\(.*\))/\1/'
64.233.169.147

Ok I'm out of bad ideas so I'll shut up now :wink:

the (well, one of many, probably) REXX way:

  PARSE VALUE D2X(ARG(1)) WITH a 3 b 5 c 7 d .
  SAY X2D(a)"."X2D(b)"."X2D(c)"."X2D(d)