I need to write a script to enter 2 IP addresses and then change them to binary.
I tried this script but it works just with numbers. I can't write the IP thus: 192.168.1.1
, but when I write it as 100
it's working fine.
#!/bin/bash
echo "Ebter the first ip"
read ip1
echo "Enter the second ip"
read ip2
a=`echo "obase=2;$ip1" | bc`
b=`echo "obase=2;$ip2" | bc`
echo $a
echo $b
What is wrong in my script?