14

Shell(函数)

 3 years ago
source link: https://blog.51cto.com/u_15561030/5341601
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Shell(函数)

原创

恩有一原 2022-05-29 18:11:21 ©著作权

文章标签 调用函数 bash 代码块 文章分类 Linux 系统/运维 阅读数177

函数默认不会执行,除非调用

函数名 () {
代码块
return N
}

演示:启动、关闭服务

#1/bin/bash
#定义函数
start () {
echo "start ...... [OK]"
#return 0
}


stop () {
echo "stop ...... [FAIL]"
}

#调用函数
start
stop

Shell(函数)_代码块
function 函数名 {
代码块
return N
}
#1/bin/bash
#:定义函数
function start {
echo "start ...... [OK]"
#return 0
}

function stop {
echo "stop ...... [FAIL]"
}

#调用函数
start
stop

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK