date
accepts input with its -d
flag, and prints it. However, input formatted like yours is treated like MM/DD/YYYY. But this shouldn't be too hard.
First, let's get input to variable:
read INPUT
Now, we need to change input from DD/MM/YYYY to MM/DD/YYYY. You can do that with sed and awk(you can also do that with awk
:
INPUT=`echo $INPUT | awk -F '/' '{t=$1;$1=$2;$2=t;gsub(" ", "/");print;}'`
Now that INPUT is in proper format, feed it to date
and make it only print the day:
date -d $INPUT +%A
Put it all together:
#!/bin/bash
read INPUT
INPUT=`echo $INPUT | awk -F '/' '{t=$1;$1=$2;$2=t;gsub(" ", "/");print;}'`
date -d $INPUT +%A