It is possible to write this script in another way to increment ip address whitout loops like this? Script, a port scanner, works fine and mine is only a question about efficiency. Sorry for my english and thanks for your answers.
#!/bin/bash
ip=$1
IFS=. read i1 i2 i3 i4 <<< "$ip"
port=$2
max=255
while [ $i1 -le $max ];do
while [ $i2 -le $max ]; do
while [ $i3 -le $max ]; do
while [ $i4 -le $max ]; do
timeout 0.4 bash -c "echo >/dev/tcp/$i1.$i2.$i3.$i4/$port" && echo "on $i1.$i2.$i3.$i4 port $port is open"
i4=$(($i4+1))
done
i4=0
i3=$(($i3+1))
done
i3=0
i2=$(($i2+1))
done
i2=0
i1=$(($i1+1))
done