过滤A类、B类、C类地址_shell脚本

2023-04-25,,

#!/bin/bash
#过滤A类、B类、C类地址
#过滤A类地址 -o 只显示符合的A类地址[1-126]
read -p "input the file absolute path:" file
egrep -o "([0-9]|[1-9][0-9]|1[01][0-9]|12[0-6])\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\>" $file |sort -n|uniq -c|sort -k 2 -rn >A_ip
#过滤B类地址【128-191】
egrep -o "(12[89]|1[3-8][0-9]|19[01])\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\>" $file |sort -n|uniq -c|sort -k 2 -rn >B_ip
#过滤C类地址【192-223】
egrep -o "(19[2-9]|2[0-1][0-9]|22[0-3])\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\>" $file |sort -n|uniq -c|sort -k 2 -rn >C_ip

《过滤A类、B类、C类地址_shell脚本.doc》

下载本文的Word格式文档,以方便收藏与打印。