You have a list to sort, then want only its first entry. Copying output between separate tools is awkward. A shell lets one tool feed another, or saves the final result to a file instead of the screen.
Support controlled command chains with |, save output with >, and append with >>. Keep files available within the same test. The reference delegates execution to Bash; it is not a from-scratch parser or pipe implementation.
Input: A command script using the shown echo, tr, sort, head, wc, and cat forms, pipes, redirection, and exit. Quoted text can contain line breaks, so a physical newline is not always the end of a command.
Output: Print the final output of each command or pipeline that is not redirected. Redirection itself is silent. Stop at exit.
Input:
echo hello | tr a-z A-Z exit
Output:
HELLO
Explanation: echo produces hello. The pipe gives that text to tr, which changes lowercase letters to uppercase. Only HELLO reaches the screen.
Input:
echo -e 'banana apple cherry' | sort | head -n 1 exit
Output:
apple
Explanation: echo supplies three lines, sort orders them, and head keeps the first. Stage order determines the result.
Input:
echo test > /tmp/algo_test.txt cat /tmp/algo_test.txt exit
Output:
test
Explanation: The first command writes to a file rather than the screen. cat reads that same file later in the test.
Input:
echo one > /tmp/algo_app.txt echo two >> /tmp/algo_app.txt cat /tmp/algo_app.txt exit
Output:
one two
Explanation: The first write creates one line. The append keeps it and adds two, so cat prints both lines in order.
Input:
echo 'one two three' | wc -w exit
Output:
3
Explanation: wc receives the text produced by echo and counts its three words. It does not count the command's own source text.
Paste this into Custom Input and run your solution.
echo first > /tmp/lesson.txt echo second > /tmp/lesson.txt cat /tmp/lesson.txt exit
What changes if the second > becomes >>?
Expected output:
second
With >, second replaces first. With >>, the existing line remains and second is appended, so cat prints first and second on separate lines.
Where should the final output go? Which stage needs to read the previous stage's output?
Pipelines connect programs through input and output streams. These controlled examples illustrate that composition; they do not demonstrate a complete terminal, job control, or sandbox security.
Apply a sliding window to numbers supplied by the test, not live benchmarks.
HELLO