Bird
0
0

How can you search recursively for the word 'config' in all files under /etc but exclude binary files from the output?

hard📝 Application Q9 of 15
Linux CLI - Text Processing
How can you search recursively for the word 'config' in all files under /etc but exclude binary files from the output?
Agrep -r 'config' /etc --exclude-dir='bin'
Bgrep -r 'config' /etc --binary-files=text
Cgrep -ri 'config' /etc --exclude='*.bin'
Dgrep -rI 'config' /etc
Step-by-Step Solution
Solution:
  1. Step 1: Understand options to exclude binary files

    The -I option tells grep to ignore binary files during recursive search.
  2. Step 2: Evaluate other options

    grep -r 'config' /etc --binary-files=text changes binary file handling but may still show binary content; C excludes files by extension but not all binaries; D excludes directories named 'bin' but not binary files.
  3. Final Answer:

    grep -rI 'config' /etc -> Option D
  4. Quick Check:

    -I skips binary files in recursive grep [OK]
Quick Trick: Use -I to skip binary files in recursive grep [OK]
Common Mistakes:
  • Confusing --exclude-dir with binary file exclusion
  • Not using -I to skip binaries
  • Assuming --binary-files=text excludes binaries

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes