bash 有两种运行模式,一个是交互式、一个是非交互式。shell
其中命令的运行有多种模式:express
●一条命令、或者赋值
bash
●管道ide
●列表(command1 && command二、command1 && command2)spa
●复合命令blog
复合命令,如表get
key |
形式 |
解释 |
---|---|---|
( ) |
(list) |
在子shell中执行 |
{ } | { list; } |
在当前shell中执行 |
(( )) |
((expression)) |
当表达式非零,返回值是0;不然是1 |
` ` |
` expression ` |
|
for |
for name [ in [ word ... ] ]it doio listtable done |
展开 in 后的项目,生成项目列表。name 依次设置成项目列表元素,然后执行 list。直到 name 获取了空的列表项目。 当省略 in 时…… |
for |
for ((expr1; expr2; expr3)) do list done |
参考C语言的语法 |
select |
select name [ in word ] do list done |
展开 in 后的项目,生成项目列表。 |
case |
case word in |
|
if |
if list; then list; [ elif list; then list; ] ... [ else list; ] fi |
|
while |
while list-1; do list-2; done |
|
until |
until list-1; do list-2; done |