Bird
0
0

What will be the output of the following command?

medium📝 Command Output Q13 of 15
Linux CLI - Pipes and Redirection
What will be the output of the following command?
echo "apple banana cherry" | tr ' ' '\n' | sort
Aapple banana cherry
Bapple banana cherry
Cbanana apple cherry
Dcherry banana apple
Step-by-Step Solution
Solution:
  1. Step 1: Break down the pipeline

    echo "apple banana cherry" outputs the string. tr ' ' '\n' replaces spaces with new lines, so words become separate lines. sort sorts these lines alphabetically.
  2. Step 2: Determine sorted output

    Words sorted alphabetically are: apple, banana, cherry, each on its own line.
  3. Final Answer:

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

    Pipe transforms and sorts words line by line [OK]
Quick Trick: Trace each pipe step to find final output [OK]
Common Mistakes:
  • Ignoring that tr changes spaces to new lines
  • Assuming sort does not change order
  • Thinking output stays on one line

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes