≡ Menu

Menu Driven Shell Script

Explains how to write a menu driven Shell script, which has following options:
1. Contents of /etc/passwd
2. List of users currently logged
3. Present handling directory (working directory)
4. Exit

Take action as per selected option

{ 8 comments… add one }
  • Sudipto January 28, 2011, 5:52 am

    write a shell script to find how many different kind of files present in current directory

    • Polux December 19, 2011, 3:52 pm

      ls -R | grep “\.” | grep -v “:” | cut -d”.” -f2 | sort | uniq
      Something like that ?

  • Laszlo August 11, 2010, 11:08 am

    A tip: using ” read -n 1 opt” line instead of ” read opt” in the script, the user should not press after the number selection, the corresponding operation immediately starts.

  • Mike Mestnik July 21, 2010, 5:43 pm

    There are several programs that do this, but currently I can only find pdmenu and can not get it to function on CentOS. cursel is another on Freshmeat, but yum and apt say it dosen’t exist.

    pdmenu works Great! Thank you Joey Hess!
    Debian packages available.

  • Trevor July 3, 2009, 7:14 pm

    This script does not seem to be working, can you advise on the following error:

    syntax error near unexpected token ‘in’
    error on line 12

    P.S. I shortened the script a little, but basically its the line starting with case $opt in which seems to be broken?

    I am running Solaris 10, does this make a difference?

    • anu April 27, 2011, 3:05 pm

      its working,,try out using ubuntu

  • al July 2, 2009, 7:58 pm

    Does anyone know how to select multiple choices at once instead of one at a time?

  • saravanan August 22, 2008, 8:30 am

    i want regularly script idea from you

Security: Are you a robot or human?

Leave a Comment