#while循环: Used to continuously execute a series of commands and to read data from input files; commands are usually test conditions
#格式如下:
#while expression
#do
# Statement to being executed if expression is true
#done
#命令执行完毕, control returns to the top of the loop and executes from the beginning to the test condition false
#例: Returns True if counter is less than 5. Counter starting from 0, each time the loop processing, counter plus 1, run the script, return the number 1-5,end
1 counter=02while5 ]3do4 Expr 1 ' #此处注意 + operator requires space on both sides #5 echo 6 Done
#while循环可用于读取键盘信息. Example: The input information is set to the variable film, and the loop is ended by ctrl-d: it will be judged as a string
1 echo " type<ctrl-d> to terminate " 2 echo -N " Enter your most liked film: " 3 Read FILM 4 do 5 echo -e " yeah! Great film The ${film} " 6 done
Linux Gvim Shell While loop