Tipical bash script option menu


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.