Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • yeah it's a shame the -eq operator cannot compare two strings, as long as both arguments are already strings, oh well. Commented Nov 10, 2017 at 0:54
  • @Alexander Mills: I have long thought that eq, being a string, should be used for string comparisons, while =, being a mathematical symbol, should be used for numerical comparisons, but alas it's not the case. Commented Nov 10, 2017 at 0:57
  • no language is perfect lol Commented Nov 10, 2017 at 1:03
  • @AlexanderMills String and integer comparisons are different, so it's important to have different symbols for them. For instance, [ 05 -eq 5 ] is true, but [ 05 = 5 ] is not -- they're different strings that represent the same integer. Also, [ 5 -lt 11 ] is true, but [ 5 '<' 11 ] is not, because 5 is less than 11 numerically, but comes after it "alphabetically" (i.e. in sorting order). BTW, = is preferred over == with test and [ ], for compatibility reasons. Commented Nov 10, 2017 at 3:06