在循环内读取是/否选项不起作用

时间:2014-12-04 07:23:47

标签: 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

==&GT;此脚本不起作用。它没有等待&#34;对于是或否选项。 我希望这个脚本能够运行。请让我知道,如何修改这个。 我在许多linux安装脚本中看到过类似的东西。

1 个答案:

答案 0 :(得分:1)

我没有对此进行测试,但应该可以使用,

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