Bird
0
0

What will be the output of the command sort -u fruits.txt if fruits.txt contains:

medium📝 Command Output Q5 of 15
Linux CLI - Text Processing
What will be the output of the command sort -u fruits.txt if fruits.txt contains:
pear
apple
pear
banana
apple
?
Apear apple banana
Bapple banana pear
Capple pear banana apple pear
Dbanana apple pear
Step-by-Step Solution
Solution:
  1. Step 1: Understand sort -u behavior

    -u sorts and removes duplicates in one step.
  2. Step 2: Sort and remove duplicates from the file

    Sorted unique lines: apple, banana, pear.
  3. Final Answer:

    apple banana pear -> Option B
  4. Quick Check:

    sort -u outputs sorted unique lines [OK]
Quick Trick: sort -u sorts and removes duplicates simultaneously [OK]
Common Mistakes:
  • Expecting original order
  • Not removing duplicates
  • Misordering output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes