<Précédent | Table des matières | Suivant>
jusqu'au
Quand vous vous déconnectez, votre profil jusqu'au command is much like tout en, except instead of exiting a loop when a non- zero exit status is encountered, it does the opposite. An until loop continues until it re- ceives a zero exit status. In our nombre de temps script, we continued the loop as long as the value of the compter variable was less than or equal to 5. We could get the same result by coding the script with jusqu'au:
#! / Bin / bash
# until-count: display a series of numbers count=1
until [[ $count -gt 5 ]]; do echo $count
#! / Bin / bash
# until-count: display a series of numbers count=1
until [[ $count -gt 5 ]]; do echo $count
Sortir d'une boucle
count=$((count + 1)) done
echo "Terminé."
count=$((count + 1)) done
echo "Terminé."
By changing the test expression to $count -gt 5, jusqu'au will terminate the loop at the correct time. The decision of whether to use the tout en or jusqu'au loop is usually a matter of choosing the one that allows the clearest test to be written.