Skip to main content
2 of 2
added 191 characters in body
Tim
  • 106.8k
  • 234
  • 651
  • 1.1k

Can the command within for-loop affect the iterations?

In Bash,

  1. the syntax of the C-like for-loop is:

    for (( expr1 ; expr2 ; expr3 )) ; do commands ; done
    

    Can the execution of commands affect the evaluations of the three arithmetic expressions expr1, expr2, and/or expr3, and therefore change the iterations (e.g. the number of iterations)?

    Or are the iterations (e.g. the number of iterations) unaffected by execution of commands in each iteration?

  2. The other syntax of the for command is:

    for name [ [in [words ...] ] ; ] do commands; done
    

    Can execution of commands in each iteration affect the iterations (e.g. the number of iterations)?

Tim
  • 106.8k
  • 234
  • 651
  • 1.1k