Skip to content

Instantly share code, notes, and snippets.

@YSaxon
Created February 2, 2022 18:10
Show Gist options
  • Save YSaxon/d2b23c36bfbcdcbeca9d2c711df78861 to your computer and use it in GitHub Desktop.
Save YSaxon/d2b23c36bfbcdcbeca9d2c711df78861 to your computer and use it in GitHub Desktop.
awk snippet to get open ports from nmap output each formatted as xxx.xxx.xxx.xxx:port
#adapted from https://itectec.com/unixlinux/parse-grepable-nmap-output-to-print-a-list-of-iptall-open-ports-with-text-utils-like-awk/
cat nmap_output.gnmap | awk '{
for (i=4;i<=NF;i++) {
split($i,a,"/");
if (a[2]=="open") printf "\n%s:%s",$2,a[1];}
print ""}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment