Bird
0
0

You run the command uniq file.txt but it does not remove duplicates as expected. What is the likely cause?

medium📝 Debug Q6 of 15
Linux CLI - Text Processing
You run the command uniq file.txt but it does not remove duplicates as expected. What is the likely cause?
AThe file is not sorted before using uniq
BThe file has no duplicate lines
Cuniq command requires -r option to remove duplicates
Duniq only works with numeric files
Step-by-Step Solution
Solution:
  1. Step 1: Recall uniq behavior

    uniq only removes adjacent duplicate lines.
  2. Step 2: Identify cause of failure

    If the file is unsorted, duplicates may not be adjacent, so uniq won't remove them.
  3. Final Answer:

    The file is not sorted before using uniq -> Option A
  4. Quick Check:

    uniq needs sorted input for duplicates removal [OK]
Quick Trick: Sort file before uniq to remove all duplicates [OK]
Common Mistakes:
  • Thinking uniq removes all duplicates regardless of order
  • Using wrong options
  • Assuming uniq works only on numbers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes