I am creating a script similar to tracerouce, when I type an IP it traces the route of arriving at the final destination, but when the route reaches the destination, the while still continues, as I correct this problem, stop when I reach the destination end?
#!/bin/bash
echo "Digite um IP: "; read ip
count=1;
while [ $count -lt 30 ]; do
ping $ip -t $count -c 1 | grep ^From | awk '{print $2}'
if [ $? -eq 0 ]; then
printf 'O salto é: '
else
echo 'Rota Indisponível'
fi
let count=$count+1;
done