腳本,輸出如下:tee命令無法正常運行(與讀取和echo)
腳本:
#!/bin/bash
#tee_with_read.sh
function tee_test()
{
echo "***This should be printed first but it is not***"
read -r -p "Enter input : "
echo "You entered : $REPLY"
}
tee_test | tee -a logfile
輸出:
$ ./tee_with_read.sh
Enter input : ***This should be printed first, but it is not***
"My Input"
You entered : "My Input"
我想追加輸出到日誌文件。 但是正如你在輸出中看到的那樣,它看起來像是第一次讀取得到執行,然後回聲這不是預期的。
我在Windows 10上使用Git Bash版本3.1.23。 由於命名管道在此版本中不可用,因此我無法使用命名管道進行日誌記錄。
'read'顯示在標準錯誤的提示。你的'echo'顯示在stdout上。 – bishop