Bird
0
0

You run sort data.txt | uniq but notice duplicates remain. What is the most likely cause?

medium📝 Debug Q14 of 15
Linux CLI - Text Processing
You run sort data.txt | uniq but notice duplicates remain. What is the most likely cause?
Asort command does not work on text files
Buniq command is misspelled
CThe file contains lines with trailing spaces or tabs
DThe file is empty
Step-by-Step Solution
Solution:
  1. Step 1: Understand how sort and uniq treat whitespace

    sort and uniq treat lines with trailing spaces or tabs as different lines, so duplicates with extra spaces won't be adjacent identical.
  2. Step 2: Check other options

    uniq misspelling would cause error, not duplicates remaining. sort works on text files. Empty file means no duplicates.
  3. Final Answer:

    The file contains lines with trailing spaces or tabs -> Option C
  4. Quick Check:

    Trailing spaces cause uniq to miss duplicates = C [OK]
Quick Trick: Check for trailing spaces if duplicates remain after sort|uniq [OK]
Common Mistakes:
  • Assuming uniq always removes duplicates regardless of spaces
  • Ignoring trailing whitespace differences
  • Thinking sort fails on text files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes