Reading Yes/No Option inside the loop, Does not wo

2019-07-21 20:40发布

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

==> This script does not work. It does not "wait" for the yes or not option. Please I want this script to work. Please let me know, how do modify this. I have seen this kind of similar things in many linux installation scripts.

标签: linux bash shell
1条回答
唯我独甜
2楼-- · 2019-07-21 21:25

I have not tested this but should work,

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
查看更多
登录 后发表回答