Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tobinary() {
- ip=$1
- ip1=$(echo "$ip" | cut -f1 -d.)
- ip2=$(echo "$ip" | cut -f2 -d.)
- ip3=$(echo "$ip" | cut -f3 -d.)
- ip4=$(echo "$ip" | cut -f4 -d.)
- b1=$(echo "obase=2; $ip1" | bc)
- b2=$(echo "obase=2; $ip2" | bc)
- b3=$(echo "obase=2; $ip3" | bc)
- b4=$(echo "obase=2; $ip4" | bc)
- printf "%0.8d.%0.8d.%0.8d.%0.8d\n" $b1 $b2 $b3 $b4
- }
- $ tobinary 34.76.28.55
- 00100010.01001100.00011100.00110111
- $ tobinary 34.76.51.131
- 00100010.01001100.00110011.10000011
- $ tobinary 255.255.192.0
- 11111111.11111111.11000000.00000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement