We Recommend

bash Cookbook: Solutions and Examples for bash Users bash Cookbook: Solutions and Examples for bash Users
bash Cookbook teaches shell scripting the way Unix masters practice the craft. It presents a variety of recipes and tricks for all levels of shell programmers so that anyone can become a proficient user of the most common Unix shell -- the bash shell -- and cygwin or other popular Unix emulation packages.


Posted By

Juanje on 06/19/08


Tagged

menu Bash options while


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

rwczippy
esritter


Tipical bash script option menu


Published in: Bash 


  1. #!/bin/bash
  2.  
  3.  
  4. while [ "$#" -gt 0 ]
  5. do
  6. case $1 in
  7. -h | --help)
  8. echo "Show program help for $(basename $0)"
  9. shift
  10. ;;
  11. -l | --list)
  12. echo "List the options"
  13. shift
  14. ;;
  15. *)
  16. echo "Other options"
  17. shift
  18. ;;
  19. esac
  20. done
  21.  

Report this snippet 

You need to login to post a comment.