linuxjishu/13830.html target=_blank class=infotextkey>awk将子网掩码换成前缀表示:
测试结果:
[root@station1 ~]# echo "224.0.0.0"|./netmask.awk
3
[root@station1 ~]# echo "255.128.0.0"|./netmask.awk
9
[root@station1 ~]# echo "255.192.0.0"|./netmask.awk
10
[root@station1 ~]# echo "255.255.0.0"|./netmask.awk
16
[root@station1 ~]# echo "255.255.192.0"|./netmask.awk
18
[root@station1 ~]# echo "255.255.255.254"|./netmask.awk
31