Bird
0
0

What does the command grep -r 'error' /var/log do?

easy📝 Conceptual Q11 of 15
Linux CLI - Searching and Finding
What does the command grep -r 'error' /var/log do?
ASearches recursively for the word 'error' inside all files in /var/log and its subfolders.
BSearches only the /var/log folder for files named 'error'.
CDeletes all files containing the word 'error' in /var/log.
DLists all files in /var/log that have the word 'error' in their name.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the grep -r option

    The -r flag tells grep to search recursively inside all files in the given directory and its subdirectories.
  2. Step 2: Analyze the command arguments

    The command searches for the text 'error' inside all files under the /var/log directory and its subfolders.
  3. Final Answer:

    Searches recursively for the word 'error' inside all files in /var/log and its subfolders. -> Option A
  4. Quick Check:

    grep -r means recursive search [OK]
Quick Trick: Remember: -r means search inside folders and subfolders [OK]
Common Mistakes:
  • Thinking -r searches only filenames, not file contents
  • Confusing grep with delete or list commands
  • Ignoring the folder path argument

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes