while与until

First, format:

  while conditions tested; do

      Loop

  done

 

Second, the test conditions

  Condition testing is to meet the conditions will have been implemented.

  such as:

    let i =0

    while i < 100;do

      echo $i

      i++

    done

    Note: here as long as i is less than 100 have been executed will continue, so the body of the loop, i must change, otherwise it will be caught in an endless loop.

Three, while if mixed with

  while conditions tested; do

    if conditional formula; then 

      command

    be

  done

Four, while reading the file

  while   read file ;do

    Loop

  done < file_name

Five, until  

  until and while the opposite, while a condition is satisfied execution cycle, until the condition is not met execution cycle

  until the test condition; do

    Loop

  done

Sixth, the combination of test conditions

  Logic and: a plurality of conditions are satisfied

    [[Condition 1 && condition 2]] 

  Or logic: a plurality of conditions are satisfied

    [[Condition 1 || condition 2]]

 

Guess you like

Origin www.cnblogs.com/kevinzr/p/12604642.html