How to make tee catch the stderr only in Linux?

How To Make Tee Catch The Stderr Only In Linux

Linux powers the vast majority of the cloud, supercomputers, and embedded systems. Modern distributions have shifted toward immutable architectures (like Fedora Silverblue) and container-first workflows.

The Modern Approach

Systemd remains the init standard, but tools like systemctl and journalctl are now complemented by eBPF-based observability tools for deeper kernel-level insights without heavy performance overhead.

Best Practices

When working with how to make tee catch the stderr only in linux, always prioritize security and maintainability. In today’s fast-paced development environment, using containerized environments (like Docker) for testing ensures that your local setup matches production, preventing the classic “it works on my machine” problem.

Similar Posts

One Comment

  1. Thanks, it really helped.

    I’ve tried to make logging of STDOUT and STDERR to separate files, but also have STDERR output in the terminal. This is what I came up with.

    test-script.sh:
    “`
    #!/bin/bash

    echo ‘Regular stdout’
    1>&2 echo ‘Error!’
    “`

    Terminal:
    “`
    ./test-script.sh > file.log 2> >(tee file-error.log >&2)
    “`

    Output:
    “`
    Error!
    “`

    file.log:
    “`
    Regular stdout
    “`

    file-error.log:
    “`
    Error!
    “`

Leave a Reply

Your email address will not be published. Required fields are marked *