i want check whether ip of version 4 or version 6. input ip address in string form. example :
ip version 4 --> 1.1.1.1 ip version 6 --> 12:1201::12:15
you check if string contains colon :, ipv6 address, otherwise ipv4 addresss:
string='1.1.1.1'; if [[ $string =~ .*:.* ]] echo "ipv6" else echo "ipv4" fi
Comments
Post a Comment