Run the live date in the linux terminal.

1.Open a Terminal: Launch a terminal on your RHEL 9.2 system.
2.Create a Script: We will create a simple Bash script that uses a while loop to continuously display the date and time.
3.Open your favorite text editor (e.g., nano or vi) and create a new script file. For example, you can name it live_datetime.sh:
nano live_datetime.sh
4.Add the Script:
Inside the text editor, add the following script:
while true; do
clear # Clear the terminal screen
date # Display the current date and time
sleep 1 # Wait for 1 second before updating
done
This script contains a while loop that continuously clears the terminal screen, displays the current date and time using the date command, and then waits for 1 second before updating.
5.Save the Script:
For nano, press Ctrl+O, then Enter to save the file, and Ctrl+X to exit.
For vi, press Esc, type :wq, and press Enter to save and exit.
6.Make the Script Executable:
Make the script executable using the chmod command:
chmod +x live_datetime.sh
7.Run the Script:
Execute the script:
./live_datetime.sh
You will see the current date and time displayed on the terminal, continuously updating every second.
8.To Stop the Display:
To stop the live date and time display, press Ctrl+C in the terminal where the script is running. This will terminate the script.
This script will continuously display the date and time on your terminal screen until you manually stop it.