简体   繁体   中英

Need a windows Nmap line for “# awk '/open/{print $2}' hostdiscovery.gnmap > livehosts.txt”

I need to do this step after first scanning ports, I have a hostdiscovery.gnmap file after that and this is my next step:

awk '/open/{print $2}' hostdiscovery.gnmap > livehosts.txt

but this is a Linux command line and I'm using windows for this project I need to do on my PC... do you know how I can get the similar windows command?

This is my source on step 2: https://www.networkstraining.com/nmap-commands-cheat-sheet/

With Powershell:

ForEach ( $lin in Get-Content hostdiscovery.gnmap ) { if ($lin -like "*open*") { $wrds=$lin.Split(" "); Write-Output $wrds[1] } } >> livehosts.txt

Read the file hostdiscovery.gnmap line by line and then if the line contains "open", split the line into the array wrds and print the first index (the second word)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM