有没有简单的方法来打印 IP_Address:port# ?因为我一进入 SED 命令,端口 :# 就被剥离了
输入文件示例
Apr 6 14:20:41 TCP 178.255.83.1:80 in
像这样的首选输出
Apr 6 14:20:41 TCP 178.255.83.1:80 in United Kingdom
egrep -w 'TCP|UDP' $Denied_IPs |
sed 's/:[^:]* in/ in/; s/:[^:]* out/ out/' |
awk '{cmd="echo "$5" | code | fgrep 'Country:' | cut -c 16-43";
cmd | getline rslt;
close(cmd);
print $1" "$2" "$3" "$4" "$5" "$6" "rslt}' >> "$IP2COUNTRY"