What are the commands for this ?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. 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.

  1. Relevant commands, code, scripts, algorithms:

case / read / echo

  1. 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 ?) ?

  1. 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).

  • What happens if you run the menu item 3 's code by itself, both with and without echo ? You might want to pipe it through od -tx1c .
  • I don't think diff is the correct way to compare numbers in shell. You did that in your other thread before.

Asides:

  • Your item 1 code doesn't satisfy the request / task (list directory).
  • Please note you don't need echo and "command substitution" to output a command's output to screen.
  • And, the backtick syntax `...` is outdated and deprecated - use $(...) for "command substitution".
  • Do you know bash 's select builtin?