Write A Bash Shell Script That Displays The Follo...
Write A Bash Shell Script That Displays The Follo...
#!/bin/bash
# Main loop
while true; do
echo
"*********************************************************************
"
echo "Please choose from the following options; type the option"
echo "number and hit the <Enter> key."
echo "a or A To display the current directory"
echo "b or B To list names of the files in a given directory"
echo "c or C To display today's date and time"
echo "d or D To display whether a file is a simple file or
directory"
echo "e or E To execute a command line"
echo "q or Q To exit the program."
echo
"*********************************************************************
"
read -n 1 choice
choice=$(echo "$choice" | tr '[:upper:]' '[:lower:]')
case "$choice" in
a) display_current_directory ;;
b) list_files ;;
c) display_date_time ;;
d) check_file_type ;;
e) execute_command ;;
q) echo "Exiting..."; exit ;;
*) echo "Invalid choice. Please try again." ;;
esac
done
Sources
1. https://github.com/HungNDHE171455/ws2-he171455-hungnd
2. https://github.com/hoangkimphu65/CODE