linux - 在循环中读取是/否选项,不起作用

标签 linux bash shell

while read line
do

read -p "Are you alright? (y/n) " RESP
if [ "$RESP" = "y" ]; then
  echo "Here i want to do something, but prompt does not wait for the answer"
else
  echo "You need more bash programming"
fi

done < find-spam-send-php-ver2.log

==> 这个脚本不起作用。它不会“等待”是或否选项。 请我希望这个脚本工作。请让我知道,如何修改这个。 我在很多linux安装脚本中都看到过这种类似的东西。

最佳答案

我还没有测试过,但应该可以,

while read line <&3
do

read -p "Are you alright? (y/n):" RESP

if [ "$RESP" = "y" ]; then
  echo "Here i want to do something, but prompt does not wait for the answer"
else
  echo "You need more bash programming"
fi

done 3< find-spam-send-php-ver2.log

关于linux - 在循环中读取是/否选项,不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27288388/

相关文章:

linux - 是否可以将 `script` 通过管道传输到例如 `xz` 以进行即时压缩而不是文件或设备?

linux - linux 进程的运行时间(以秒为单位)

c - 在哪里更改 LD_LIBRARY_PATH

bash - 尝试 awk 文件,但无法分配足够的内存。有什么替代方案或调整吗?

linux - 如何打印开头以制表符分隔的 find 命令的输出

android - 如何在 Android 设备上运行 Linux 命令?

sql - 谷歌 BQ : Running Parameterized Queries where Parameter Variable is the BQ Table Destination

linux - 为什么 `stack --version` 显示的版本与安装的版本不同?

c - Bash中的增减运算符是Undefined Behavior吗?

linux - 将运行时日志存储在文件夹中