Hi there. I'm trying to teach myself UNIX but the book I bought is a bit confusing. I'm trying out this exercise and I think I'm on the right track, but I'd appreciate any suggestions on how to improve what I have so far. Also, I'm not clear on how to use the read command to utilize the user's input (#'s 4-7). I appreciate your help!
Code:
#!/bin/bash
while:
do
clear
# Display menu
echo
echo "*************************************************************"
echo "Please choose from the following options; type the"
echo "option number and hit the <Enter> key."
echo
echo " 1) To list names of the files in the current DIR"
echo " 2) Display today's date and time"
echo " 3) Display a sorted list of people currently logged on"
echo " 4) Display whether a file is a file or a DIR"
echo " 5) Create a backup for a file"
echo " 6) Find a user by First of Last name in /etc/passwd file"
echo " 7) Find the manual pages for a specific command"
echo " 8) Exit"
echo
echo "*************************************************************"
read option
case "$option" in
1) echo "The files in the current DIR are: "
ls -l
echo "Hit <Enter> to continue."
read ignore
;;
2) echo "The current date is: "
date
unset date
echo "Hit <Enter> to continue."
read ignore
;;
3) echo "The following is a list of the academic scholars"
echo "currently logged in:"
who | cut -d " " -f1 | sort
echo "Hit <Enter> to continue."
read ignore
;;
4) echo "Enter file to determine whether a "simple" file or a"
echo "directory:"
5) echo "Enter the file you would like to create a backup for:"
6) echo "Enter user's first or last name:"
7) echo "Enter command for which you would like the manual:"
8) echo "Thank You for using Skynet"
echo "Remember: Skynet is the Future"
sleep 1.5
clear
exit 0
;;
*) echo "Invalid option; try running the program again."
exit 1
;;
esac
done.
exit 0