An and list has the form
command1 && command2command2 is executed if, and only if, command1returns an exit status of zero.
(当且仅当返回0(成功)时候,Command2才会执行)
An or list has the form
command1 || command2
command2 is executed if, and only if, command1 returns a non-zero exit status.
(当且仅当Command1返回非零值(执行失败)时候,Command2才会被执行。)
greatesteclipse 于 2009-08-20 11:34:23发表:
不错,真仔细
l460618498 于 2009-08-19 16:47:48发表:
学习一下啊
wangyu 于 2009-08-19 16:45:12发表:
哦,学习了
deepwhite 于 2009-08-19 09:14:47发表:
你说的是“管道”,即 ‘|’,而不出‘||’
Bash Reference Manual中写道:
An and list has the form
command1 && command2command2 is executed if, and only if, command1returns an exit status of zero.
(当且仅当返回0(成功)时候,Command2才会执行)
An or list has the form
command1 || command2
command2 is executed if, and only if, command1 returns a non-zero exit status.
(当且仅当Command1返回非零值(执行失败)时候,Command2才会被执行。)
for more info, see: http://www.gnu.org/software/bash/manual/bashref.html
wangyu 于 2009-08-18 17:08:30发表:
[i=s] 本帖最后由 wangyu 于 2009-8-18 17:10 编辑 [/i]
;一行太长,用;结束后不执行,与后面的一起执行
&&是执行完一个命令后执行下一个,且前一个出错,后面的不能执行
||是前一个命令的输出作为后一个的输入
不知对否