Signal9Signal9 — home
online
back to labs

tee: Split a Pipeline to Screen and File

MediumCommand Line Guru10-15 min
The brief

tee duplicates a stream: what flows in goes to stdout AND into a file — so you can watch a pipeline live while keeping a transcript, or save an intermediate stage without breaking the pipe.

The log /root/logs/app.log has ERROR lines buried in noise. Build ONE pipeline that:

1. greps the ERROR lines and saves them to /root/out/errors.txt WITH tee (not a plain >), while the same lines flow onward…

2. …to wc -l, whose count you save to /root/out/error-count.txt.

That's the tee idiom: capture the middle of a pipeline without stopping it. Grading checks errors.txt holds exactly the ERROR lines and error-count.txt holds their count.

What you'll do
  • Use tee to save the grep results mid-pipeline into errors.txt
  • Let the same stream continue to wc -l, saved in error-count.txt

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