Signal9Signal9 — home
online
back to labs

Streams & Redirection: Split the Output

EasyLinux Fundamentals10-15 min
The brief

A noisy program at /root/noisy.sh prints normal results to stdout and warnings/errors to stderr — mixed together on screen. Your job is to pull those two streams apart and then total a set of logs. Write each result under /root/answers/ (already created):

1. out.txt — run /root/noisy.sh and capture ONLY its stdout (the result lines) here, using >.

2. err.txt — capture ONLY its stderr (the warning/error lines) here, using 2>. (You can do both in one command: bash /root/noisy.sh >out.txt 2>err.txt.)

3. logtotal.txt — a single number (wc's own N total line is accepted too): the TOTAL line count across every *.log under /root/logs2, produced by feeding find's output into a counter (find … | xargs, or find … -exec).

The skill: stdout (1) and stderr (2) are separate wires — redirect each on its own — and a pipe/xargs turns a list of files into a command's arguments.

What you'll do
  • Capture noisy.sh's stdout alone into out.txt with >
  • Capture noisy.sh's stderr alone into err.txt with 2>
  • Total the lines across all *.log files via find + xargs/-exec into logtotal.txt

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.