Sunday, 27 January 2008

Shell Script: Getting Date

If you need to get today's date and yesterday's date into a variable when using shell scripting

yesterday=$(date +%Y-%m-%d --date=yesterday )

today=$( date +%Y-%m-%d --date=now )


Simple as that!!

Check out the man page of date and you'll be surprised at the things it can report!

No comments: