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
  • 71,145
  • 9
  • 121
  • 139
Nirbhay Singh
  • 379
  • 1
  • 5
  • 17

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
  • 216,930
  • 22
  • 195
  • 267