实现效果:
多个IP添加指定掩码并去重
代码语言:javascript复制root@BJ-CentOS7 ~ # cat ip.txt
61.151.163.73
180.163.22.108
101.91.24.25
101.91.24.37
root@BJ-CentOS7 ~ # cat ip.txt | awk -F "." -v OFS='.' '{print $1,$2,$3,"0/24"}' | sort | uniq
101.91.24.0/24
180.163.22.0/24
61.151.163.0/24
root@BJ-CentOS7 ~ #