This is probably old news to most of you, but hey I just figured it out last night so... Me and a buddy were goofing off in class and realized most applications can use ip's with 3 octets. So, to do this it's w.x.y.z for four octets right? To make it three it would be w.x.y*256+z. Pretty simple right? Now we thought, how can make this go further? So I tried w.x*(256 squared)+y*256+z and bam! Works. Okay, let's try it with just one! okay, so, w*(256 cubed)+x*(256 squared)+y*256 +z. Although this isn't that great, it's a fun tidbit. Here's a shell script I wrote to output an inputed IP into 1, 2, and 3 octs. Hopefully someone else finds this as interesting as I did :p
x="$1"
x1=`echo $x | awk -F . {'print $1'}`
x2=`echo $x | awk -F . {'print $2'}`
x3=`echo $x | awk -F . {'print $3'}`
x4=`echo $x | awk -F . {'print $4'}`
grr=`expr "256" "*" "256" "*" "256"`
y0=`expr "$x1" "*" "$grr"`
y1=`expr "$x2" "*" "65536"`
y2=`expr "$x3" "*" "256"`
outcome3=`expr "$y2" + "$x4"`
outcome2=`expr "$y1" "+" "$y2" + "$x4"`
outcome1=`expr "$y0" + "$y1" "+" "$y2" + "$x4"`
echo "------------------------------------------"
echo "Input IPv4: $x"
echo "------------------------------------------"
echo "Outcome with 3 Octets: $x1.$x2.$outcome3"
echo "Outcome with 2 Octets: $x1.$outcome2"
echo "Outcome with 1 Octets: $outcome1"