Automation, Orchestration, and Scripting

In Bash, what are the results of the tests [ 05 -eq 5 ] and [ 05 = 5 ]?

Show the answer

Correct answerA. The -eq test succeeds and the = test fails

AWhy this is right: -eq compares integer values, so 05 equals 5, while = compares strings, and "05" is not "5".

BWhy not this: = compares character by character, and the leading zero makes the strings differ.

CWhy not this: -eq compares numbers, and 05 has the integer value 5, so that test succeeds.

DWhy not this: The results are reversed; -eq compares numbers and = compares strings.

The -eq operator converts both operands to integers, so 05 and 5 are equal. The = operator compares strings, and "05" differs from "5", so the test fails. Treating the two operators as interchangeable is a common mistake.