Quick Nmap ping sweep and output to grep-able format

grep hacking linux nmap ping scan security

Start with laying out what range of IP addresses you want to scan. I’d suggest keeping it limited to your specific targets. Then run this as root:

nmap -sn -v -oG nmapped.txt

Here is our what our output file reads:

Nmap 6.47 scan initiated Wed Oct 15 21:15:32 2014 as: nmap -sn -v -oG nmapped.txt # Ports scanned: TCP(0;) UDP(0;) SCTP(0;) PROTOCOLS(0;) Host: () Status: Up Host: () Status: Up Host: () Status: Up Host: () Status: Down Host: () Status: Up Host: () Status: Up

and so on….

To grep for IP address of hosts that are up, run;

grep Up nmapped.txt | cut -d" " -f2

This should give you a nice output of all IP addresses for hosts found to be online.

grep Up nmapped.txt | cut -d" " -f2

Intro to Nmap

Introduction to grep

The author would love to hear your comments. Let us discuss at Twitter @qasimchadhar.