【问题标题】:Bash: tree direction in sub-shell working incorrectlyBash:子外壳中的树方向工作不正确
【发布时间】:2013-03-02 14:05:55
【问题描述】:

不久前我在 CentOS 机器上测试了它,它运行良好。现在在另一台机器上,我尝试了这个,但它无法工作。哪里不对?

command 2> >(tee stderr.log >&2) && exit

我收到了这条消息。

sh: syntax error near unexpected token `>'

有什么建议吗?

【问题讨论】:

    标签: bash stderr tee


    【解决方案1】:

    答案在错误消息中。传统的 Bourne shell (sh) 不支持进程替换(例如 >(command))。你没有使用 Bash。您可以使用 chsh 命令更改默认 shell。

    【讨论】:

    • @hexacyanide 是的,在许多系统上sh 实际上是bash,但bash 中有几种兼容模式,它们通常取决于shell 的启动方式。因此,即使sh 在内部使用bash,它的行为通常也会与您以bash 调用它时不同。如果这是在脚本中,您应该通过将 shebang 行从 #!/bin/sh 更改为 #!/bin/bash 来解决您的问题。
    • @hexacyanide:但是请注意,在 Ubuntu 上 /bin/sh 表示 dash,而不是 bash
    • @hexacyanide:您在出现错误的系统上使用的是什么操作系统或发行版?
    • @hexacyanide:CentOS 使用bash 符号链接到sh,相当于运行bash --posix。这些模式不支持进程替换。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多