shell entry --shell the common statement

Shell common statement

for statement
format

for NUM in 1 2 3
for NUM in {1..3}
for NUM in `seq 1 3` 或者 for NUM in `seq 1 2 10`
do
done

Examples
Here Insert Picture Description
Here Insert Picture Description

With seq way
Here Insert Picture Description
Here Insert Picture Description

while statement

while 条件
do
Done

Examples
Here Insert Picture Description
Here Insert Picture Description

Because the conditions have been established, so i have been executed in

until usage
format and while the same time, until the condition is false is executed
Here Insert Picture Description
Here Insert Picture Description

The condition is true, is not performed
Here Insert Picture Description
Here Insert Picture Description

The if statement

if
then
elif
then
。。。
else
fi

Here Insert Picture Description
Here Insert Picture Description

case statement

case
word1)
action1
;;
word2)
action2
;;
........
*)
action_last
esac

Case and IF
Case is named, is performed only once, if every time judge

expect

expect an automatic response command for interactive commands executed automatically
spawn is in the monitoring program expect, after its interaction issues raised by running the command monitors
send answers to questions sent to the interactive command
"\ r" denotes carriage
exp_continue indicate when the problem is not continue to answer the following questions in the presence of
expect eof complete answer questions marked exit expect the environment
interact to answer question mark left in the finished interactive interface
to define variables set NAME [lindex $ argv n] , starting from 0 count

Expect first need to download the software
Example: ssh connection automatically
Here Insert Picture Description
Here Insert Picture Description

Script statements controller

exit n		脚本退出,退出值为n
break		退出当前循环
continue	提前结束循环内部的命令,但不终止循环

Guess you like

Origin blog.csdn.net/zhaoliang_Guo/article/details/91807614