Bird
0
0

When using diff to compare two files, what happens if both files have duplicate lines that differ? How does diff handle these duplicates?

hard📝 Conceptual Q10 of 15
Linux CLI - Viewing and Editing Files
When using diff to compare two files, what happens if both files have duplicate lines that differ? How does diff handle these duplicates?
Adiff stops comparing after the first duplicate difference
Bdiff ignores duplicate lines and only shows unique differences
Cdiff merges duplicate lines and shows only one difference
Ddiff compares each line in order and shows all differences including duplicates
Step-by-Step Solution
Solution:
  1. Step 1: Understand diff line-by-line comparison

    diff compares files line by line in order, including duplicates.
  2. Step 2: Identify handling of duplicates

    It shows all differences, even if lines are duplicated, without merging or ignoring.
  3. Final Answer:

    diff compares each line in order and shows all differences including duplicates -> Option D
  4. Quick Check:

    diff shows all line differences, duplicates included [OK]
Quick Trick: diff compares files line by line, showing all differences [OK]
Common Mistakes:
  • Thinking diff merges duplicates
  • Assuming diff ignores duplicates
  • Believing diff stops early

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes