#!/bin/bash i=0 while read ip; do arr[$i]="$(nmap -sT -T Insane -p 139 $ip | grep -i "Interesting ports on" | cut -d ' ' -f4 | cut -d ':' -f1)" ((i++)) done < iplist.txt echo scan finished i=0 while read ip; do echo $ip : ${arr[$i]} echo ---------------------------------------- ((i++)) done < iplist.txt