Bird
0
0

What happens when set -x is enabled in a shell script?

easy📝 Conceptual Q1 of 15
Linux CLI - Environment and Configuration
What happens when set -x is enabled in a shell script?
AThe shell prints each command before executing it
BThe shell exits immediately if a command fails
CThe shell ignores errors and continues execution
DThe shell disables command substitution
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of set -x

    This option makes the shell print each command to the terminal before running it, helping with debugging.

  2. Step 2: Compare with other options

    set -e causes exit on error, not printing commands. Other options do not relate to printing commands.

  3. Final Answer:

    The shell prints each command before executing it -> Option A
  4. Quick Check:

    set -x = print commands [OK]
Quick Trick: Use set -x to see commands as they run [OK]
Common Mistakes:
  • Confusing set -x with set -e
  • Thinking set -x stops script on error
  • Believing set -x disables command substitution

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes