前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >一步步成为linux大神——bash shell中管道和其他命令分隔符的优先级

一步步成为linux大神——bash shell中管道和其他命令分隔符的优先级

作者头像
大神带我来搬砖
发布2018-04-28 17:08:25
1.8K0
发布2018-04-28 17:08:25
举报

一般在bash中,用“|”作为管道,即pipeline,还可以用“;”之类的分隔符连接多个命令。那么下面这个命令的输出是什么呢?

代码语言:javascript
复制
date; who |wc

根据https://www.gnu.org/software/bash/manual/bashref.html里的说明,管道是'|'或者'|&'分隔的命令

A pipeline is a sequence of one or more commands separated by one of the control operators ‘|’ or ‘|&’

而list是‘;’, ‘&’, ‘&&’或者 ‘||’分隔的管道

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.

因此上面的命令中,"who | wc"作为一个管道,再和前面的"date"结合

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.03.24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档