小编kas*_*yap的帖子

如何从shell脚本中的case调用函数?

大家好,我正在尝试使用 case 语句运行 shell 脚本

opt=$1
case $opt
in
    u) function1 ;;
    g) function2 ;;
    *) exit ;;
esac

function1()
{
    xyz commands
}

funciton2t()
{
    xyz commands
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

function1: command not found
Run Code Online (Sandbox Code Playgroud)

bash scripts

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

bash ×1

scripts ×1