【1.6】shell使用 getopts -p -f 之类的参数
usage(){ echo $1 echo '$#': $# action "error" /bin/false echo "usage: install_mysql.sh -F -f mysql-x-x.tar.xx -d /data/mysql -l /data/mysql_log -b /data/backup -p xxxxx" } while getopts :f:d:b:p:l:F opt do case "$opt" in h) usage && exit ;; f) mysql_tar=$OPTARG ;; d) datadir=$OPTARG ;; l) logdir=$OPTARG ;; b) backupdir=$OPTARG ;; F) force_install=1 ;; p) password=$OPTARG ;; *) usage && exit;; esac done
usage(){echo $1echo '$#': $#action "error" /bin/false        echo "usage: install_mysql.sh  -F   -f   mysql-x-x.tar.xx  -d /data/mysql  -l /data/mysql_log -b /data/backup -p xxxxx"
}
while getopts :f:d:b:p:l:F optdo        case "$opt" in                h) usage && exit ;;                f) mysql_tar=$OPTARG ;;                d) datadir=$OPTARG ;;                l) logdir=$OPTARG ;;                b) backupdir=$OPTARG ;;                F) force_install=1 ;;                p) password=$OPTARG ;;                *) usage && exit;;        esacdone
                    
                
                
            
        
浙公网安备 33010602011771号