我想在 bash 下将命令的标准输出复制到标准错误。像这样的东西:
$ echo "FooBar" (...)
FooBar
FooBar
$
其中 (...) 是重定向表达式。这可能吗?
最佳答案
将 tee 与/dev/stderr 一起使用:
echo "FooBar" | tee /dev/stderr
或使用 awk/perl/python 手动进行复制:
echo "FooBar" | awk '{print;print > "/dev/stderr"}'
echo "FooBar" | perl -pe "print STDERR, $_;"
关于bash - 将标准输出复制到标准错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3141738/