Question: Using greeting script with Dynamic Variables Greeting Script with Dynamic Variables Write a Bash script that dynamically greets the user based on the current time

Using greeting script with Dynamic Variables Greeting Script with Dynamic Variables
Write a Bash script that dynamically greets the user based on the current time and their username. The script should: - Display Good morning, [username] if the current hour is less than 12.- Display Good afternoon, [username] if the current hour is between 12 and 18.- Display Good evening, [username] if the current hour is greater than 18.
Hint: Use $(date +%H) to get the current hour and $USER for the username. Commands like date in Unix or Linux systems are utility programs provided by the operating system to perform specific tasks from the command line or within scripts. The date command, specifically, is used to display or set the systems date and time. To find out more about the date command, type man date in your terminal. The manual page for date will explain how to format the output, set the system date, and more.
$USER is an environment variable representing the current logged-in users name. You may refer back to Module 14 for Environment Variables.
Expected Output:
niroshinie@MacBook-Pro-17 OtherResources %./greeting.sh
Good morning, niroshinie.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!