Multiple choice technology operating systems

How could you check if two strings are equal?

  1. test $a -eq $b
  2. test a -eq b

  3. test $a -equal $b
  4. test $a = $b
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The 'test' command (or [) uses = for string equality comparison in shell scripting. Options A and B incorrectly use -eq which is for numeric comparisons. Option C uses -equal which is not valid test syntax. Option D correctly uses = for string comparison.