Bird
0
0

Given two files with these contents:

medium📝 Command Output Q13 of 15
Linux CLI - Viewing and Editing Files
Given two files with these contents:

file1.txt:
apple
banana
cherry

file2.txt:
apple
banana
date

What will be the output of diff file1.txt file2.txt?
A2c2 < banana --- > banana
BNo output (files are identical)
C3c3 < cherry --- > date
DError: files not found
Step-by-Step Solution
Solution:
  1. Step 1: Compare lines one by one

    Lines 1 and 2 are the same (apple, banana). Line 3 differs: 'cherry' vs 'date'.
  2. Step 2: Understand diff output format

    diff shows line number and change type: '3c3' means line 3 changed. Then shows old line with '<' and new line with '>'.
  3. Final Answer:

    3c3 < cherry --- > date -> Option C
  4. Quick Check:

    Line 3 differs [OK]
Quick Trick: Look for first differing line number in diff output [OK]
Common Mistakes:
MISTAKES
  • Assuming diff shows all lines
  • Confusing line numbers in output
  • Expecting no output for different files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes