0
option=n
while [ "$option" != "Y" -o "$option" != "y" ]
do
echo "Enter SIDNAME"
read SIDNAME

echo "Enter TNSALIAS"
read TNSALIAS

echo "Enter FQDN of the RDS"
read RDS

echo "Cofigration details provides as"
echo "SIDNAME : " $SIDNAME
echo "TNSALIAS: " $TNSALIAS
echo "FQDN of the RDS :" $RDS

echo "Do you want continue with this information? Enter y/n"
read option
done

I am try to achieve that if user enter any thing except Y then the loop re runs but this is a infinite loop not breaking even if I enter Y.

I know I am making this some silly mistake.

Help is really appreciated.

Inian
  • 80,270
  • 14
  • 142
  • 161
Nirbhay Singh
  • 399
  • 2
  • 6
  • 18

1 Answers1

1

You need -a instead of -o in the condition. You want to terminate when it's Y or y, i.e. it should run while it's not Y AND it's not y.

Also, in bash you can use the [[ condition and use a pattern on the right hand side:

while [[ $option != [Yy] ]]
choroba
  • 231,213
  • 25
  • 204
  • 289