Break vs Continue

Okay so I am having trouble understand what the computer will do with a code like this

 if [ file exists ] ; then
                        echo
                        echo "Found the file"
                        blah blah blah
                        for i in `blah blah blah` ; do
                                echo $i
                        done >thing ; sed "/$blah/d" thing >thing2
                        break
                else
                        continue
                fi
        done
                        blah blah blah
                        blah blah blah

I am just trying to figure out what would happen when you hit the break and if the file was not found what would happen if you hit continue. Does the done command effect what would happen next if you hit either break or continue?

Hi, it helps to properly indent the code:

  if [ file exists ] ; then
    echo
    echo "Found the file"
    blah blah blah
    for i in `blah blah blah` ; do
      echo $i
    done >thing
    sed "/$blah/d" thing >thing2
    break
  else
     continue
  fi
done

Then it becomes apparent that the last "done" belongs to a missing loop statement, probably one line above the if statement. The "break" statement means "end the loop now", the "continue" statement means stop processing further statements in the loop and continue with the next iteration in the loop.

I agree with Scrutinizer but would add that the continue is un-needed in that situation.

removing the else and continue lines would also end that iteration and "continue" to the next iteration since it is already at the end of the loop code (immediately above done).

That is just extra overhead and time that will never serve a valid purpose.

If there was more code after that if statement then the continue would be valid, in this case there is not.