Get day from date variable

Ok...this is really bumming me out because it seems like it should be simple, but for some reason, I just can't get it...I've also googled and searched these forums, and haven't found exactly what I'm looking for...

I have a date in mm/dd/yyyy format in a variable...I need to extract the abbreviated name of the day of week from that variable...so I start with this:
10/18/2012

and end up with this:
Thu

To be very clear about what is messing me up, I know that to do this from the system date, I can just use `date '+%A'`, but I DON'T need the day of the system date...I need the day of a date input as a parameter and stored in a variable...and no I can't use `date --date...` Please help!

So whats the problem....?

date --date="$Date_var" +%A

This thread might help.

or even with -d option :slight_smile:

date -d "$Date_var" +"%A"

Will try the link you posted, bipinajith. Was hoping for an awk or perl one-liner, but sometimes we just don't get what we want, right? :smiley:

As for the other two replies, as stated in the original post, I can not use `date --date ...` I also can not use `date -d ...` I wish it was that easy, but my understanding is that these two options are GNU only, and I don't have it.
:wall:

perl -e 'use POSIX qw/strftime/; @x = split /\//, $ARGV[0]; print strftime("%a", 0, 0, 0, $x[1], $x[0]-1, $x[2]-1900)' "10/22/2012"
1 Like

This is EXACTLY what I wanted...You are an absolute saint!

@dbiggied : well you get everything in this forum...UNIX.com !! :slight_smile: just like how you can get any result on UNIX machine itself:b: