Quick Nmap ping sweep and output to grep-able format

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

  • -sn (No port scan) .This option tells Nmap not to do a port scan after host discovery, and only print out the available hosts that responded to the scan.
  • -v: Increase verbosity level (use -vv or more for greater effect
  • -oG : Output scan in grep-able format
  • : Scans IP address range to Change it to your target range.

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

Show Comments

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