我有一个脚本可以指导用户安装我的软件,我想编写一个日志文件,以防出现问题并且用户需要支持。
该脚本如下所示:
while true; do
echo "This script will help you with the installation. Do you wish to proceed?"
echo "(1) Yes"
echo "(2) No"
read proceed
case $proceed in
1 ) break;;
* ) echo "Aborting."; exit 8;;
esac
done
unset proceed
然后我通过使用运行它./install.ksh | tee /var/log/myinstall.log
,一切正常,但用户对问题的输入未记录。当我在命令echo $proceed
后添加时read
,它会写入日志但显示两次,如下所示:
This script will help you with the installation. Do you wish to proceed?
(1) Yes
(2) No
1 #this is the input which is not written to the log
1 # this is the echo which is written to the log
我现在的问题是如何抑制命令的输出read
,或者如何echo
仅将其写入文件而不写入 STDOUT?