-3

ICode

Input & Output

So the problem is i am not getting the desired output. Need some help in the problem statement as i am a newbie to the BashScript!!

Barmar
  • 669,327
  • 51
  • 454
  • 560

1 Answers1

1

-eq is for numeric comparisons and all of the strings YES, Y, N and NO evaluate to zero. Hence they'll all match each other.

You should be using = rather than -eq.

However, you can also use regular expressions in bash with something like:

[[ $input =~ [Yy] ]]

That seems much more readable to me.

paxdiablo
  • 814,905
  • 225
  • 1,535
  • 1,899