Get the App
SLTechnology News&Howtos  ›  Servers  › 

Use for loop statements

Shulou Source: shulou.com Published: 2022-06-02 08:29:57 09月18日 Update

When using a for loop statement using a for loop statement, you need to specify a variable and a list of possible values, and repeat the same command sequence for each different value until the variable value runs out of the loop. The "value list" we are talking about here is the execution condition of the for statement, which includes multiple objects with the same attributes, which need to be specified by raindrops (such as: address book, IP address is to read different variable values, which is used to execute the same set of commands one by one. Format 1:for variable value in value list do (start execution) command sequence done pattern 2: for ((number of words)) do (start execution) the Operand of the command sequence donefor statement is a variable with a name specified by the user, and a list of values is preset for the variable through the in keyword, and multiple values are separated by spaces. The sequence of commands between do.done is called "loop body", in which the execution statement needs to refer to variables to complete the corresponding task.

First assign the first value in the list to the variable and execute do. The command sequence in the done loop body; then assigns the second value in the list to the variable and executes the command sequence in the loop body. And so on, until all the values in the list are used up, and then jump to done to end the loop.

Tags: Loops commands variables sequences statements loops values different same between multiple objects and so on tasks keys keywords including name address number of words Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Information Xiaomi Shulou Technology NVidia