grep IP adress with open port nmap

bash, grep

Solution

It works with egrep :

nmap 192.168.0.0/24 -sU -p 44555 | grep -B3 open | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}"  > output.txt

Problem

I'm trying to make this script to grep IP adresses with open port from nmap but I can't do it the right way. I have something like this: ``` nmap 192.168.0.0/24 -sU -p 44555 | grep -oP "([0-9]{1,3}\.){3}[0-9]{1,3}" >output.txt ``` But this is taking all IP's open and closed. example output nmap: ``` Nmap scan report for 79-119-0-248.rdsnet.ro (79.119.0.248) Host is up (0.033s latency). PORT STATE SERVICE 27023/udp open|filtered unknown Nmap scan report for 79-119-0-249.rdsnet.ro (79.119.0.249) Host is up (0.032s latency). PORT STATE SERVICE 27023/udp closed unknown ``` Only the ones are open/filtered I want Thanks

Original source

Related problems