Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
If the user enters option 1, your program should display the list of entries in the current
directory. For option 2, it runs the vim editor. For option 3, it provides your login id (only)
from the id command. For option 4, it should prompt the user for the directory he/she wish
to compare the number of entries with the current directory, and display the directory
name which contains the more entries. If the user enters a directory name which does not
exist, your program should state that the directory does not exist. To quit, user will choose
option 5. Your program should continue to execute until the user selects option 5.
- Relevant commands, code, scripts, algorithms:
case
/ read
/ echo
- The attempts at a solution (include all code and scripts):
#!/bin/bash
while :; do
read -p "Please enter your name: " name
echo "Welcome to $name's menu"
echo "1. Display the list of all files in the current directory"
echo "2. Run vim (or nano)"
echo "3. See your login id"
echo "4. Compare entries in directories"
echo "5. Quit"
read -p "Choose your option(1-5): " num
case $num in
1) echo "`ls | wc -l`";;
2) echo "`vim`";;
3) echo "`id -u $username`";;
4) echo "";;
5) exit;;
*) echo "Wrong input"
esac
done
everthing is right but case 3 isn't right and everytime i choose it, it would crash putty..
for the 4th option, i know the command is diff
but how would i input the code so that the user can choose any directory he want to compare the entries to his current directory ( diff
/ wc
?) ?
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Sheridan college, Oakville, canada, Syed tanbeer, ["https://academics.sheridancollege.ca/programs/computer-systems-technology-software-development-and-network-engineering"
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).