title: Nested Bash while loop, inner loop is only loop looping
body: <p>This is a very simple script but I can't seem to get it right. This code is supposed to print out class C IP addresses from 192.168.0.0 - 192.168.255.255 but all that prints out is 192.168.0.0 - 192.168.0.255. For some reason my outer loop won't loop. I'm sure it is something stupid but this could be helpful for those people learning nested looping in shell scripts. Any other advice is welcome!</p>
  
  <pre><code>#! /bin/sh
  network_id="192.168."
  count1=-1
  count2=-1
  while [ "$count1" -le 254 ]
  do
      count1=$(($count1+1))
      while [ "$count2" -le 254 ]
      do
          count2=$(($count2+1))
          printf "%s%s%s%s\n" $network_id $count1 "." $count2
      done
  done
  exit 0
  </code></pre>