« Vista Secure? NBL! | Main | Yesterday / Tomorrow (in C for AIX) »

February 24, 2007

Yesterday / Tomorrow (in shell)

This is the most elegant shell solution I have come across:

#!/bin/sh
let today=`date '+%s'`
let yesterday=$today-86400
let tomorrow=$today+86400
echo "He is the same yesterday (" `date -r $yesterday` "),"
echo "  today (" `date -r $today` ") and"
echo "  tomorrow (" `date -r $tomorrow` ")."

Of course, this doesn't work on AIX....

Posted by Ozguru at February 24, 2007 07:00 AM