diff --git a/advanced/learning_bash_scripting.md b/advanced/learning_bash_scripting.md index 881d11b..c81bb08 100644 --- a/advanced/learning_bash_scripting.md +++ b/advanced/learning_bash_scripting.md @@ -454,6 +454,34 @@ echo "or may I call you $first?" It is worth discovering what happens when you supply too many or to little values. Please try this out! +# Coding challenge - Birthday **day** + +Write me `bash` program that asks for your date of birth and prints the day of the week that was. +Like the output below. + +``` +waldek@server:~$ bash birthday.sh +what is your birthday (day month year)? 07 10 1986 +you where born on a Tuesday +``` + +
+Spoiler warning! + +```bash +#!/bin/bash + +read -p "what is your date of birth? (day month year) " day month year + +day_of_the_week=$(date +%A -d "$month/$day/$year") + +echo "you where born on a $day_of_the_week" +``` + +
+ + + ## With command line arguments We can create a similar behaviour but with command line arguments.