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

我有这个:

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.

因此,因为您从文件中读取行而不是从终端提示中读取未显示的行.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...