Concatenation awk outputs

Posted by Rookie_22 on Stack Overflow See other posts from Stack Overflow or by Rookie_22
Published on 2010-06-13T12:38:35Z Indexed on 2010/06/13 12:42 UTC
Read the original article Hit count: 128

Filed under:

I'm using regex to parse NMAP output. I want the ip addresses which are up with the corresponding ports open. Now I've a very naive method of doing that:

awk '/^Scanning .....................ports]/ {print substr ($2,1,15);}' results.txt
awk '/^[0-9][0-9]/ {print substr($1,1,4);}' results.txt | awk -f awkcode.awk

where awkcode.awk contains the code to extract numbers out of the substring. The first line prints all the ips that are up and 2nd gives me the ports. My problem is that I want them mapped to each other. Is there any way to do that? Even sed script would do.

© Stack Overflow or respective owner

Related posts about bash