Tag: getopts

  • Bash menu in bash with getopts

    A little more sophisticated script than the former bash menu example to get some arguments from command line. #!/bin/bash while getopts “u:p:” opt; do case $opt in u) echo “-u was triggered, Parameter: $OPTARG” dbuser=”$OPTARG” ;; p) echo “-p was triggered, Parameter: $OPTARG” dbpass=”$OPTARG” ;; \?) echo “Invalid option: -$OPTARG” exit 1 ;; 🙂 echo…