Bird
0
0

Given a file input.txt containing:

medium📝 Command Output Q4 of 15
Linux CLI - Pipes and Redirection
Given a file input.txt containing:
apple
banana
cherry

What is the output of the command sort < input.txt?
Aapple banana cherry
Bbanana apple cherry
Capple banana cherry
Dcherry banana apple
Step-by-Step Solution
Solution:
  1. Step 1: Understand sort command with stdin redirection

    sort reads lines from input.txt via < and sorts them alphabetically.
  2. Step 2: Check the sorted order

    Lines are already in alphabetical order: apple, banana, cherry, so output matches input lines separated by newlines.
  3. Final Answer:

    apple banana cherry -> Option C
  4. Quick Check:

    sort < file outputs sorted lines with newlines [OK]
Quick Trick: sort reads lines from stdin and outputs sorted lines [OK]
Common Mistakes:
  • Assuming output is space-separated
  • Confusing input and output order
  • Ignoring newline characters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes