【发布时间】:2019-06-03 11:21:11
【问题描述】:
我有一个简单的任务要在 shell 脚本中完成 - 将命令输出重定向到变量以及标准输出。我已经通过redirect command output into variable and standard output in ksh,并想出了:
VAR1=$(ps -u "${USER}" | awk 'NR>1 {print $NF}' | tee > /proc/$$/fd/1)
但是以上对我不起作用。输出显示在STDOUT 上很好,但它没有保存在VAR1 中。我在这里错过了什么?
【问题讨论】: