所以我想尝试做以下事情:
while read line; do
read userInput
echo "$line $userInput"
done < file.txt
Run Code Online (Sandbox Code Playgroud)
所以说file.txt有:
Hello?
Goodbye!
Run Code Online (Sandbox Code Playgroud)
运行该程序将创建:
Hello?
James
Hello? James
Goodbye!
Farewell
Goodbye! Farewell
Run Code Online (Sandbox Code Playgroud)
问题(自然地)成为用户输入读取从stdin读取,在我们的例子中是文件.txt.有没有办法改变它从临时读取到终端的位置以获取用户输入?
注意:我正在使用的文件长度为200,000行.每条线长约500个字符.因此,如果需要,请记住这一点
bash ×1