我想把命令的stdout复制到stderr以及bash下.就像是:
$ echo "FooBar" (...)
FooBar
FooBar
$
Run Code Online (Sandbox Code Playgroud)
其中(...)是重定向表达式.那可能吗?
mar*_*rco 47
与/ dev/stderr一起使用tee:
echo "FooBar" | tee /dev/stderr
Run Code Online (Sandbox Code Playgroud)
或使用awk/perl/python手动执行复制:
echo "FooBar" | awk '{print;print > "/dev/stderr"}'
echo "FooBar" | perl -pe "print STDERR, $_;"
Run Code Online (Sandbox Code Playgroud)
bra*_*blc 18
使用流程替换:http://tldp.org/LDP/abs/html/process-sub.html
echo "FooBar" | tee >(cat >&2)
Tee将文件名作为参数并将输出复制到此文件.使用进程替换,您可以使用进程而不是文件名,>(cat)
并且可以将此进程的输出重定向到stderr >(cat >&2)
.
归档时间: |
|
查看次数: |
9075 次 |
最近记录: |