while read -r line
do
name="$line"
echo "$name"
count=$line
nmap -oG output.txt -T4 -f -iL iplist.txt $line1
done < iplist.txt
you have three names for the contents of a line from iplist.txt : line , name , and count . But in your invocation of nmap you use $line1 . Since line1 has not been defined in your script anywhere, that will expand to an empty string unless line1 is an exported variable in your environment.
I don't have nmap on my system. The Linux nmap man page isn't clear about what servers(s) it attempts to scan if no targets are given on the command line. Maybe it seems like an infinite loop because you are trying to scan every server on the internet???
If no target is given, nmap just exists, telling you that 0 target has been scanned.
-iL iplist.txt That's the target, a list of possible IPs if the filename is an indication.
It is not running in an infinite loop. It is running that list on each iteration of the loop.
Try that one.
while read -r line
do
echo "$line"
nmap -oG output.txt -T4 -f $line
done < iplist.txt