【发布时间】:2019-11-19 17:25:48
【问题描述】:
我正在尝试在我的脚本中创建 2 个变量以将错误和输出重定向到文件并仅显示屏幕中的错误和其他变量以仅在屏幕中显示输出。当我把它作为一个变量它不起作用。变量为空。有什么帮助吗?
#!/bin/bash
timestamp="`date +%Y%m%d%H%M%S`"
displayonlyerror="2>&1 >> /tmp/postinstall_output_$timestamp.log | tee -a /tmp/postinstall_output_$timestamp.log"
displayoutput="2>&1 |tee -a /tmp/postinstall_output_$timestamp.log"
echo "No screen session found" $displayoutput
ech "No screen session found" $displayerror
【问题讨论】:
-
那么最好的处理方法是什么?
-
非常感谢。它奏效了。
标签: bash shell variables stdout stderr