Redirecting Stderr: Split the Streams
MediumCommand Line Guru10-15 minA program writes normal output to stdout (fd 1) and errors to stderr (fd 2) — two separate wires. A bare > only captures stdout; the errors still spray across your screen. The fix is to redirect fd 2 explicitly.
Run the provided noisy tool, /root/bin/noisy.sh, three ways:
1. Capture ONLY its stdout into /root/out/out.txt → /root/bin/noisy.sh > /root/out/out.txt
2. Capture ONLY its stderr into /root/out/err.txt → 2> redirects fd 2
3. Capture BOTH, merged in one file /root/out/all.txt → > file 2>&1 (order matters!)
It prints a few hundred lines, different on every box, so typing the files by hand is not an option. Grading re-runs noisy.sh and compares, so each file must hold exactly the right stream, in order. The classic trap in #3: 2>&1 > file sends stderr to the old stdout (the terminal) before stdout is redirected — you must write > file 2>&1.
- Redirect stdout alone into out.txt
- Redirect stderr alone into err.txt
- Merge both streams into all.txt with > file 2>&1
Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.
