\ Computer \ OS \ *Nix \ Sh \

Output to file and screen

Merge stderr into stdout, then pipe to tee -a so the stream is appended to a file and still shown on screen.

2>&1 | tee -a <output_file>
  • 2 — stderr.
  • > — redirect.
  • &1 — stdout.
  • | — pipe.
  • tee — write to file and to the screen.
  • -a — append.
  • <output_file> — destination file
Updated: 2026 Aug 19