Bird
0
0

Identify the error in this script snippet:

medium📝 Debug Q6 of 15
Bash Scripting - Text Processing in Scripts
Identify the error in this script snippet:
grep "pattern" -r /home/user
AThe -r option should come before the pattern
BThe directory path is missing
CThe pattern must be in single quotes
Dgrep cannot search recursively
Step-by-Step Solution
Solution:
  1. Step 1: Check grep option order

    Options like -r must come before the pattern argument in grep syntax.
  2. Step 2: Correct syntax

    Correct command is: grep -r "pattern" /home/user
  3. Final Answer:

    The -r option should come before the pattern -> Option A
  4. Quick Check:

    Options precede pattern in grep command [OK]
Quick Trick: Place options before pattern in grep commands [OK]
Common Mistakes:
MISTAKES
  • Putting options after pattern
  • Assuming quotes must be single
  • Thinking grep can't search directories

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes