gpt4 book ai didi

linux - 当 i/p 从文件重定向时读取不提示

转载 作者:可可西里 更新时间:2023-11-01 11:47:44 24 4
gpt4 key购买 nike

我有这个:

while read -r line; do echo "hello $line"; read -p "Press any key" -n 1; done < file

hello This is line 1
hello his is line 2
hello his is line 3
hello his is line 4
hello his is line 5
hello his is line 6
hello his is line 7

为什么我没有看到“按任意键”的提示?

最佳答案

引自man bash:

-p prompt
Display prompt on standard error, without a trailing new
line, before attempting to read any input. The prompt is
displayed only if input is coming from a terminal.

因此,因为您从文件中读取行而不是从终端提示中读取行,所以不会显示。

关于linux - 当 i/p 从文件重定向时读取不提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6398908/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com