Bird
0
0

What is the main purpose of using sort | uniq together in a bash pipeline?

easy🧠 Conceptual Q11 of 15
Bash Scripting - Text Processing in Scripts
What is the main purpose of using sort | uniq together in a bash pipeline?
ATo get a sorted list with duplicates removed
BTo count the number of lines in a file
CTo sort lines but keep duplicates
DTo find the longest line in a file
Step-by-Step Solution
Solution:
  1. Step 1: Understand what sort does

    The sort command arranges lines in alphabetical or numerical order.
  2. Step 2: Understand what uniq does after sorting

    The uniq command removes duplicate adjacent lines, so sorting first groups duplicates together for removal.
  3. Final Answer:

    To get a sorted list with duplicates removed -> Option A
  4. Quick Check:

    sort + uniq = sorted unique lines [OK]
Quick Trick: Always sort before uniq to remove all duplicates [OK]
Common Mistakes:
MISTAKES
  • Using uniq before sort, which misses duplicates
  • Thinking uniq counts lines instead of removing duplicates
  • Assuming sort removes duplicates by itself

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes