Skip to content

Instantly share code, notes, and snippets.

@thrawn01
Created February 6, 2012 16:47
Show Gist options
  • Save thrawn01/1753234 to your computer and use it in GitHub Desktop.
Save thrawn01/1753234 to your computer and use it in GitHub Desktop.
rebinds output of the currently running shell
#! /usr/bin/env bash
echo "before exec"
TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT:-"%F-%H%M%S"}
LOGFILE=test.$(date "+$TIMESTAMP_FORMAT")
# Redirect stdout/stderr to tee to write the log file
exec 1> >( tee "${LOGFILE}" ) 2>&1
echo "after exec"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment