Using the Unix Epoch timestamp for file naming

Another aide-mémoire today, illustrated via a small script.

I was musing on file version numbering (yes I know about SVN et al, but sometimes they are overkill) and considered using the time represented as the number of seconds elapsed since the Unix Epoch, seems like a simple approach wrapped into the file and filename, what am I missing?

Oh yes, a handy way to remember CASE syntax in bash as well..

#!/bin/bash
OS=`uname -s`

case $OS in
                 SunOS)
                 DATE=/usr/bin/date
                 ;;
                 Darwin) DATE=/bin/date
                 ;;
                 Linux) DATE=/bin/date
                 ;;
                 *) echo “Unable to determine *nix variant, so we bailed out.”
                 exit 1
esac

echo “Time, as seconds since Epoch `$DATE +%s`, OS determined to be $OS”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s