Bird
0
0

What does the logical operator ! do in bash scripting when used inside [ ]?

easy🧠 Conceptual Q2 of 15
Bash Scripting - Conditionals
What does the logical operator ! do in bash scripting when used inside [ ]?
APerforms OR operation
BPerforms AND operation
CChecks if file exists
DNegates the condition
Step-by-Step Solution
Solution:
  1. Step 1: Identify the role of ! operator

    The ! operator negates or reverses the result of the condition it precedes.
  2. Step 2: Confirm its usage inside [ ]

    Inside [ ], ! means NOT, so it negates the test condition.
  3. Final Answer:

    Negates the condition -> Option D
  4. Quick Check:

    ! means NOT (negation) inside [ ] [OK]
Quick Trick: Use ! to reverse a condition inside [ ] [OK]
Common Mistakes:
MISTAKES
  • Thinking ! means AND or OR
  • Using ! outside [ ] incorrectly
  • Confusing ! with -o or -a

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes