using linux answer the following questions 1) John is trying to cut on his Briti
ID: 3835784 • Letter: U
Question
using linux answer the following questions
1) John is trying to cut on his British diet for the week. On Monday, at tea time, the computer should show tell him "you're allowed 5 cups of tea". The next day, same time, he would be allowed 4 cups; then 3 cups the next day, etc. When he can't drink tea, the computer shows the message "No tea today". Write a script diet.sh that schedules all these messages to be displayed.
2)Write a script When the user closes the script (using Ctrl+C), the script closes but the user will see the message "I am still in your Shell" in the shell 5, 10, and 15 minutes later.
Explanation / Answer
Shell script:
#!/bin/bash
now="$(date +'%A')"
echo $now
case $now in
"Monday") echo "you're allowed 5 cups of tea";;
"Tuesday") echo "you're allowed 4 cups of tea";;
"Wednesday") echo "you're allowed 3 cups of tea";;
"Thursday") echo "you're allowed 2 cups of tea";;
"Friday") echo "you're allowed 1 cups of tea";;
*) echo "No tea today";;
esac
Schedule this to run daily using crontab
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.