You can choose with awk for printing only in certain cases and not for everyone.
For example, the following corresponds to the last field, if it contains ssh (but you can also check for 22) then it prints IP.
nmap -PN -p 22 --open -oG - 192.168.*.* | awk '$NF~/ssh/{print $2}' > sshopen.txt
Elisiano petrini
source share