Bootstrap FreeKB - Bash (Scripting) - Move onto next value in a loop (continue)
Bash (Scripting) - Move onto next value in a loop (continue)

Updated:   |  Bash (Scripting) articles

The continue operator is used to move onto the next value in a loop. For example, consider the following script. This script will print the text one two three four to the console.

#!/bin/bash

values="one two three four"

for value in $value {
  echo $value
}

 

In this example, if two is detected, the loop will move onto the next value. In this example, text one three four will be printed to the console.

#!/bin/bash

values="one two three four"

for value in $value {

  if [ "$value" == "two" ]; then
    continue
  fi

  echo $value
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 412079 in the box below so that we can be sure you are a human.