#!/bin/bash
ip2long(){
j=0;
k=0;
for i in `echo $* | tr '.' '\n' | tac;`
do
j="$j+($i*2^$k)"
k=$(($k+8));
done;
echo $j|bc
}
ip2long $1
convert IP address to integer bash function
Reply
#!/bin/bash
ip2long(){
j=0;
k=0;
for i in `echo $* | tr '.' '\n' | tac;`
do
j="$j+($i*2^$k)"
k=$(($k+8));
done;
echo $j|bc
}
ip2long $1