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 Display Good afternoon, username if the current hour is between and Display Good evening, username if the current hour is greater than
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 loggedin users name. You may refer back to Module for Environment Variables.
Expected Output:
niroshinie@MacBookPro OtherResources greetingsh
Good morning, niroshinie.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
