awk处理nmap扫描结果
接到个任务,要对大量的主机ip进行扫描:
扫描加过滤脚本贴到底下
#!/bin/bash ### use nmap scan aliyun echo "********Start scan********" cat aliyun.txt | grep -Ev '^(#|$)' | while read line; do nmap -Pn $line |awk '/Nmap scan/ {printf "\n""\033[1;32m" $5 "\033[0m ""\n"} /Host/ {print $0} /PORT/ {print $0} /tcp/ {print $0}' >> check.txt echo "scan $line ok!" done echo "********All done********"
过滤前的格式:
过滤后的格式: