美文网首页
3.2 Shell命令(Shell Command)

3.2 Shell命令(Shell Command)

作者: Doerthous | 来源:发表于2017-10-17 02:14 被阅读0次

待完善

3.2.1 简单命令(Simple Command)


由blanks分隔,由control operators结尾的word序列。

3.2.2 管道(Pipeline)


定义

Pipeline指一个由 ‘|’ 或 ‘|&’ 分隔的命令序列。

例子

c1 | c2: c1's stdout => c2's stdin
c1 |& c2 <=> c1 2>&1 | c2: c1's stdout and c1's stderr => c2's stdin

3.2.3 列表(List)


定义

List指一个包含一个或多个Pipeline的,由‘;’, ‘&’, ‘&&’, ‘||’分隔的,由‘;’, ‘&’, ‘\n’ 结尾的序列。

特性

‘;’: 由‘;’分隔的命令顺序执行。
‘&’: 由‘&’分隔的命令将在子shell中执行,即在后台执行。

类别
  • and list: command1 && command2, 当且仅的command1的退出码为0时command2才执行。
  • or list: command1 || command2, 当且仅当command1的退出码为非0时command2才执行。
返回状态

List的返回状态是该list中最后一个命令的退出码。

3.2.4 复合命令(Compound Command)


相关文章

网友评论

      本文标题:3.2 Shell命令(Shell Command)

      本文链接:https://www.haomeiwen.com/subject/afjruxtx.html