Write a menu driven program which has the following options : 1.Contents of etc/passwd 2.List of the users who have logged in 3.Present working directory 4.Exit The menu should be placed approximately in the center of the screen.
choice=0 while [ $choice -lt 4 ] do tput clear echo "1. contents of etc/passwd" echo "2. list of the users who have logged in" echo "3. Present working directory" echo "4. Exit" echo "Enter your choice " read choice if [ $choice -eq 1 ] then cat /etc/passwd | more read a elif [ $choice -eq 2 ] then who | more read a elif [ $choice -eq 3 ] then pwd read a fi done ------------------------------------------------------------------- output ------------------------------------------------------------------- 1. contents of etc/passwd 2. list of the users who have logged in 3. Present working directory 4. Exit Enter your choice 1 root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin news:x:9:13:news:/etc/news: uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin gopher:x:13:30:gopher:/var/gopher:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin rpm:x:37:37::/var/lib/rpm:/bin/bash vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin nscd:x:28:28:NSCD Daemon:/:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin 1. contents of etc/passwd 2. list of the users who have logged in 3. Present working directory 4. Exit Enter your choice 2 mca258 pts/0 Nov 19 12:28 (128.66.203.10) 1. contents of etc/passwd 2. list of the users who have logged in 3. Present working directory 4. Exit Enter your choice 3 /home/symca/mca258 ----------------------------------------------------------------------