在 while 读取循环中读取输入似乎不起作用
while read line
do
echo "get some input from the user"
read response
done < some_file.txt
Run Code Online (Sandbox Code Playgroud)
执行不会像读取在循环之外那样暂停。为什么是这样?是否有在 while 读取循环中读取输入的解决方法?
gle*_*man 17
让内部读取命令使用 stdin,并为 while 循环使用不同的文件描述符
while read -u 3 line; do
read -p "get some input from the user" response
done 3< some_file.txt
Run Code Online (Sandbox Code Playgroud)