-   Linux - Newbie (
-   -   remove hostname using sed (

gilad73 07-05-2012 02:24 AM

remove hostname using sed
I am trying to format my out put from the results of an nmap command. I would like to basically generate a simple two column list with ip addresses and mac address. I have managed to strip out most of what I don't want with combinations of awk, grep and sed. my problem is not all the rows are the same, some contain host names and other don't. This makes it hard for me to use cut to remove the "Unknown" in the last column. I am struggling with a regex to use in a sed to remove the hostnames from rows that contain it. thoughts? here is some sample output: 6A:8D:93:5E:1C:6E Unknown 00:14:5E:46:E7:B7 corp 72:B5:01:E3:FE:D7 Unknown 00:14:5E:1E:1F:80 corp 22:DB:5C:22:AE:3C Unknown 00:21:5E:F0:A3:39 corp 22:F2:31:65:65:E4 Unknown C8:4C:75:68:E3:42 Unknown 46:36:B9:18:8E:CB Unknown 96:7B:62:06:E0:B6 Unknown 00:16:41:37:43:AD USI 00:21:86:14:6C:4E USI E4:1F:13:1F:16:CE Unknown

evo2 07-05-2012 02:32 AM


instead of trying to parse the default output of nmap, have you considered using the various nmap options that modify the output format? Check the "OUTPUT:" section in the namp man page, or for more details see



gilad73 07-05-2012 03:27 AM

Thanks Evo2! I played around with some of the different out puts (in particular XML and converting to HTML), but that really provides more information than I need. Basically I just want the IP/Mac of up and running servers. I will use this file and join on another file to provide users with specific info they need for their machines.


All times are GMT -5. The time now is 02:41 AM.