2016-01-29 47 views

回答

9

read暫停腳本從標準輸入讀取默認情況下,它被重定向到文件,所以它從文件中獲取行。你可以回重定向到終端:

read -p "Press Enter to continue" </dev/tty 

另一種選擇是使用不同的FD的文件重定向

while read -u 3 
do 
    ... 
done 3< test.txt 
+0

Thankyou Barmar,它工作:) – Dheeraj

+1

或讓交互式讀取命令使用stdin,並將文件重定向放在不同的文件描述符 –