Bird
0
0

Why does grep 'pattern' file1 file2 prefix output lines with filenames?

hard📝 Conceptual Q10 of 15
Linux CLI - Text Processing
Why does grep 'pattern' file1 file2 prefix output lines with filenames?
ABecause the files are binary
BBecause the pattern is case-insensitive
CBecause grep is run with -v option
DBecause multiple files are searched, grep shows filename to identify source
Step-by-Step Solution
Solution:
  1. Step 1: Understand grep output format

    When searching multiple files, grep prefixes matched lines with the filename to show which file the line came from.
  2. Step 2: Check other options

    Case sensitivity, binary files, or -v option do not cause filename prefixes.
  3. Final Answer:

    Because multiple files are searched, grep shows filename to identify source -> Option D
  4. Quick Check:

    Multiple files searched = filename prefix in output [OK]
Quick Trick: Multiple files searched? grep shows filename prefix [OK]
Common Mistakes:
  • Thinking case-insensitive adds filename
  • Assuming binary files cause prefix
  • Confusing -v option effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes