Multiple choice technology operating systems

Count the number of errors in the statement if [password = password1] then echo password else password

  1. 0

  2. 4

  3. 1

  4. 2

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The shell script has 4 syntax errors: (1) missing space after [ and before ] in the test condition, (2) missing semicolon or newline before then, (3) password in the else branch is not a valid command (should be echo password), and (4) missing fi to close the if statement. Proper shell syntax requires strict spacing and complete if-then-else-fi structure.