-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
  • 741,623
  • 53
  • 500
  • 612
Manoj Kumar
  • 19
  • 1
  • 8

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
  • 854,327
  • 234
  • 1,573
  • 1,953