惜风不起、唯有努力!
shell循环调用函数

shell循环调用函数

#!/bin/bash

v=$2

function all_colour(){
    red=31; gr=32; ye=33; bl=34; wh=37
    printf "\033[4;${ye}mlllllllllllll\033[0m\n"
    printf "\033[4;${gr}mlllllllllllll\033[0m\n"
    printf "\033[4;${red}mlllllllllllll\033[0m\n"
    printf "\033[4;${bl}mlllllllllllll\033[0m\n"
    printf "\033[4;${wh}mlllllllllllll\033[0m\n"
}

function helps(){
    echo "
    -f      执行main函数
    -e      输出字母e
    -E      输出字母E
    -d      输出字母d
    "
}

function main(){
    echo "my is functions $1"
}

while getopts "x:afeEd" INPUT_OPT
do
    case $INPUT_OPT in
        a) helps;;
        f) main $v;;
        e) echo "e";;
        E) echo "E";echo "my is E";;
        d) echo "d";;
    esac

done

发表回复

您的电子邮箱地址不会被公开。