fish - 在 fish shell 中同时管道 stdout 和 stderr

标签 fish

我知道这已经是一个问题一段时间了,我发现了很多关于它的讨论,但是我没有得到最终完成它的方法:同时管道,stdout 和 stderr。在 bash 中,这很简单:

cmd 2>&1 | cmd2

最佳答案

这种语法也适用于 fish 。一个演示:

$ function cmd1
      echo "this is stdout"
      echo "this is stderr" >&2
  end

$ function cmd2
      rev
  end

$ cmd1 | cmd2
this is stderr
tuodts si siht

$ cmd1 &| cmd2
rredts si siht
tuodts si siht

文档:https://fishshell.com/docs/current/index.html#redirects

关于fish - 在 fish shell 中同时管道 stdout 和 stderr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37530641/

相关文章:

linux - 如何在 fish shell 中的每个 session 中永久设置 env?

android - gradle 和 react-native 与 fish shell

shell - 如何在 fish shell 中打印到标准错误?

bash - 如何在 Fish shell 中为手册页着色?

fish - 如何为 fish 中的某些脚本设置临时?

fish - 有没有办法像 bash 一样在命令前加上变量赋值?

shell - 在 nix-shell 中配置 Fish shell 提示符

shell - 在 Cygwin 中设置默认 Shell

shell - 将字符串拆分为命令行参数

node.js - 运行 npm 脚本时 npm 使用哪个 shell?