title: Using shell, how to skip to next element in a for loop?
body: <p>Here's what my script should do: it pings 5 times the IP address of each line of an imported text file. If the IP is unreachable 3 of the 5 times, it echo "it's down!" and (should) move on to the next IP... Except I don't know how to configure this "skip" part.
  Here is my current code:</p>
  
  <pre class="lang-sh prettyprint-override"><code>FILE=file.txt
  unreachableIP=0
  
  while IFS='' read -r line || [ -n "$line" ]; do
      set -- $line
  
      for (( i=1; i&lt;=5; i++ ))
      do
          echo "Ping $1 $i times"
          ping -c 1 $1
          if [ "$?" = 0 ]
          then
              echo "reachable"
          else
              echo "unreachable"
              ((unreachableIP++))
              echo $unreachableIP
              if [ $unreachableIP -eq 3 ]
              then
                  echo "it's down!"
                  unreachableIP=0
              fi
          fi
      done
  done &lt; $FILE
  </code></pre>
  
  <p>Example: if the IP address is reachable 1st time, unreachable 2nd time, unreachable 3rd time and unreachable 4th time, I want the script to move to the next IP (next line) and not try to ping a 5th time.
  Here is the <code>file.txt</code>:</p>
  
  <pre><code>8.8.8.8 GoogleDNS
  1.1.1.1 CloudFlareDNS
  213.1.1.1 SomeFakeIPForDebug
  </code></pre>
  
  <p>Thanks for your help.</p>
  
  <p>EDIT: I don't want to use break because it will stop pinging the other IPs too... and I would like it to only stop pinging the current IP.</p>