#!/bin/sh

awk -F ' *[|\n]+ *' -v OFS='|' -v RS='\n*Nmap scan report for ' '$2 == "Host is up." { if (split($1, a, /[ ()]+/) == 1) $2 = "No_DNS"; else { $1 = a[2]; $2 = a[1] }; print }' nMap-Output.b.e.02.txt
# Adapted from https://trisquel.info/forum/extracting-cidr-and-country-code-address-block#comment-159102
