Monday, January 12, 2009

A little tee please

Welcome to this weeks exciting new episode of Practical Shell Scripting. I'm under the gun to get a project done at work so weeks is a quickie. If you ever wanted to pipe output to both a file and the screen. Here's a fast one liner that will do it for you.

#!/bin/bash

LOGFILE="test.log"


echo "foo" | tee -a $LOGFILE



The trick is the -a for append which tee uses to print to stdio as well as where ever you direct it.

No comments: