By default, Nmap displays results of the scan to the terminal, but it is often preferable to save the results to a file for later inspection. This is particularly useful when scanning a large network as the scan output can span tens of pages. Some tools even take Nmap scan files as input, which is yet another reason to save the scan results to a file. Nmap can store the results of its scans in four different formats:
This is the same format as what is displayed to the terminal during a scan. The only difference is that the command-line options are printed at the top of the file as a reminder of what the scan was configured to do, and some runtime warnings are omitted.
This format presents the results with one host per line in a concise fashion, meant to be easily processed with Unix text tools such as grep, sed, awk, and diff. Because of the condensed nature of this format, not all scan output may be preserved this way.
This is the most powerful format, as the entire scan results are represented in highly structured XML for easy parsing by third-party applications. Unlike the Grepable format, all scan output is present in these files.
This format is presented solely as a joke and is simply the Normal output passed through a text-mangling filter.
These various output formats can be selected with the -o
type
filename
option, where the type is N, G, X
, or S
. An additional option, -oA
basename
, is supported to simultaneously write the scan output in the Normal, Grepable, and XML formats. With this option, the files are named basename
.nmap, basename
.gnmap, and basename
.xml. Multiple output formats can be specified using -o
flags as well. For example, to write the output of a scan in normal and XML formats simultaneously, you would type:
sudo nmap -oN
normal_output
-oX
xml_output
target