Bird
0
0

Identify the error in the command: grep -i 'hello' file.txt -r

medium📝 Debug Q14 of 15
Linux CLI - Linux Basics and Terminal
Identify the error in the command: grep -i 'hello' file.txt -r
AThe -r option is misplaced and invalid here
BThe quotes around 'hello' are incorrect
CThe file name should come before options
DThere is no error in this command
Step-by-Step Solution
Solution:
  1. Step 1: Understand grep options and order

    '-i' is a valid option for case-insensitive search. '-r' is for recursive search but must come before arguments.
  2. Step 2: Check option placement

    Options should come before arguments. Here, '-r' is after the file name, which is incorrect and causes error.
  3. Final Answer:

    The -r option is misplaced and invalid here -> Option A
  4. Quick Check:

    Options before arguments [OK]
Quick Trick: Put all options before arguments in commands [OK]
Common Mistakes:
  • Placing options after arguments
  • Misusing quotes
  • Assuming no error when order is wrong

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes