#!/bin/bash exec > >(tee "/tmp/foo") perl -le '$|=1; for (0..10) { print; sleep 1 }'