adds new birthday ex

This commit is contained in:
waldek 2022-07-11 11:50:00 +02:00
parent a5ca242827
commit b9bd04bb1e
1 changed files with 28 additions and 0 deletions

View File

@ -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. It is worth discovering what happens when you supply too many or to little values.
Please try this out! 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
```
<details>
<summary>Spoiler warning!</summary>
```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"
```
</details>
## With command line arguments ## With command line arguments
We can create a similar behaviour but with command line arguments. We can create a similar behaviour but with command line arguments.