bash - script to Change ip address format, -
i'm trying write bash script convert ip address cidr quad-style.
for example
192.168.1.1/24 ===>192.168.1.1 255.255.255.0
i tried write
#!/bin/bash echo "enter ip" read ip b=`echo $ip | cut -d/ -f1` a=`echo $ip | cut -d/ -f2` if a=24 ; echo "$b 255.255.255.0" fi if a=25; echo "$b 255.255.255.128" fi
i'm getting output:
1.1.1.1 255.255.255.0 1.1.1.1 255.255.255.128
when i'm entering /24 or /25 /26 didn't wrote in if condition, i'm getting same output, wrong in script?
in bash can use
if (( == 24 ));
Comments
Post a Comment