From every line of nmap network scan output I want to store the hosts and their IPs in variables (for further use additionaly the "Host is up"-string):

The to be processed output from nmap looks like:

```
Nmap scan report for samplehostname.mynetwork (192.168.1.45)
Host is up (0.00047s latency).

```

thats my script so far:

```
#!/bin/bash

while IFS='' read -r line
do
  host=$(grep report|cut -f5 -d' ')
  ip=$(grep report|sed 's/^.*(//;s/)$//') 
  printf "Host:$host - IP:$ip"
done < <(nmap -sP 192.168.1.1/24)

```

The output makes something I do not understand. It puts the "Host:" at the very beginning, and then it puts "IP:" at the very end, while it completely omits the output of $ip.

The generated output of my script is:

```
Host:samplehostname1.mynetwork
samplehostname2.mynetwork
samplehostname3.mynetwork
samplehostname4.mynetwork
samplehostname5.mynetwork - IP:

```

In separate, the extraction of $host and $ip basically works (although there might a better solution for sure). I can either printf $host or $ip alone.

What's wrong with my script? Thanks!