#!/usr/bin/env bash send_some_output() { echo "hello" echo "here" echo "goodbye" } exec > >(tee -a ./x.out) 2>&1 send_some_output >&2