Confirm the Day of the Week Based on a Timestamp

I recently created a Unix Questions and Answers page, if you have a Unix question – feel free to ask it there using the submit form and I’ll do my best to help you out.

Today’s Unix question is this:

How can we write a shell script in unix to find the day of the week when date is given?

The solution for this is even simpler: there’s no need for Unix scripting, all you need is to have GNU date command at your disposal. I’ve already shown you all the basic date/time calculations using this great tool, and that’s just another way of using it.

How to find a Day of the week based on timestamp

All you need is to know the base date. Let’s say I’m interested in October 16th, 2009. Here’s how easy it is to confirm that day will be Friday:

ubuntu$ date -d "Oct 16 2009" "+%a"
Fri

That’s it – enjoy!

See also: