【问题标题】:What does "|&" mean in Bash?“|&”在 Bash 中是什么意思?
【发布时间】:2016-05-24 22:11:43
【问题描述】:

例如

echo "aaa" |& cat

|& 在这里是什么意思?

有推荐的网站来查找这些吗?由于大多数搜索引擎不支持搜索特殊字符。

【问题讨论】:

    标签: bash


    【解决方案1】:

    来自man 1 bash管道部分:

    [时间 [-p]] [ ! ] 命令 [ [|⎪|&] 命令2 ... ]

    如果使用|&,command的标准错误,除了它的标准输出,通过管道连接到command2的标准输入

    所以它就像管道运算符|,但同时管道standard outputstandard error

    【讨论】:

    • @BallpointBen 完全正确。来自gnu.org/software/bash/manual/bash.pdfIf ‘|&’ is used, command1’s standard error, in addition to its standard output, is connected to command2’s standard input through the pipe; it is shorthand for 2>&1 |.
    【解决方案2】:

    此操作符将标准输出和标准错误从左侧传送到右侧。

    Bash reference manual 具有所有运算符的综合索引,您可以在其中查找这些运算符。

    【讨论】:

      【解决方案3】:

      如果使用'|&',command1的标准错误,除了它的标准输出,通过管道连接到command2的标准输入;它是 2>&1 | 的简写。标准错误到标准输出的这种隐式重定向是在命令指定的任何重定向之后执行的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-11-17
        • 2012-04-19
        • 2015-09-27
        • 2015-09-18
        • 1970-01-01
        • 1970-01-01
        • 2012-05-12
        • 1970-01-01
        相关资源
        最近更新 更多