手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网站运营>建站经验>列表

bash manual (保存)

来源:互联网 作者:west263.com 时间:2008-04-16
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

If the pipeline is not executed asynchronously (see section 3.2.3 Lists of Commands), the shell waits for all commands in the pipeline to complete.

Each command in a pipeline is executed in its own subshell (see section 3.7.3 Command Execution Environment). The exit status of a pipeline is the exit status of the last command in the pipeline. If the reserved word `!' precedes the pipeline, the exit status is the logical negation of the exit status of the last command.

--------------------------------------------------------------------------------
[ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? ]

3.2.3 Lists of Commands
A list is a sequence of one or more pipelines separated by one of the operators `;', `&', `&&', or `||', and optionally terminated by one of `;', `&', or a newline.

Of these list operators, `&&' and `||' have equal precedence, followed by `;' and `&', which have equal precedence.

A sequence of one or more newlines may appear in a list to delimit commands, equivalent to a semicolon.

If a command is terminated by the control operator `&', the shell executes the command asynchronously in a subshell. This is known as executing the command in the background. The shell does not wait for the command to finish, and the return status is 0 (true). When job control is not active (see section 7. Job Control), the standard input for asynchronous commands, in the absence of any explicit redirections, is redirected from /dev/null.

Commands separated by a `;' are executed sequentially; the shell waits for each command to terminate in turn. The return status is the exit status of the last command executed.

The control operators `&&' and `||' denote AND lists and OR lists, respectively. An AND list has the form command1 && command2


command2 is executed if, and only if, command1 returns an exit status of zero.

An OR list has the form command1 || command2


command2 is executed if, and only if, command1 returns a non-zero exit status.

The return status of AND and OR lists is the exit status of the last command executed in the list.

--------------------------------------------------------------------------------
[ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? ]

3.2.4 Looping Constructs
Bash supports the following looping constructs.

Note that wherever a `;' appears in the description of a command's syntax, it may be replaced with one or more newlines.


until
The syntax of the until command is: until test-commands; do consequent-commands; done


Execute consequent-commands as long as test-commands has an exit status which is not zero. The return status is the exit status of the last command executed in consequent-commands, or zero if none was executed.

while
The syntax of the while command is: while test-commands; do consequent-commands; done

Execute consequent-commands as long as test-commands has an exit status of zero. The return status is the exit status of the last command executed in consequent-commands, or zero if none was executed.


for
The syntax of the for command is:
for name [in words ...]; do commands; done


Expand words, and execute commands once for each member in the resultant list, with name bound to the current member. If `in words' is not present, the for command executes the commands once for each positional parameter that is set, as if `in "$@"' had been specified (see section 3.4.2 Special Parameters). The return status is the exit status of the last command that executes. If there are no items in the expansion of words, no commands are executed, and the return status is zero.

An alternate form of the for command is also supported:

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


First, the arithmetic expression expr1 is evaluated according to the rules described below (see section 6.5 Shell Arithmetic). The arithmetic expression expr2 is then evaluated repeatedly until it evaluates to zero. Each time expr2 evaluates to a non-zero value, commands are executed and the arithmetic expression expr3 is evaluated. If any expression is omitted, it behaves as if it evaluates to 1. The return value is the exit status of the last command in list that is executed, or false if any of the expressions is invalid.


The break and continue builtins (see section 4.1 Bourne Shell Builtins) may be used to control loop execution.

--------------------------------------------------------------------------------
[ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? ]

3.2.5 Conditional Constructs

if
The syntax of the if command is:
if test-commands; then
consequent-commands;
[elif more-test-commands; then

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!