shell script 变量、常量和函数
函数
shell函数有两种语法:
- 第一种
function name{
commands
return
}
- 第二种
name (){
commands
return
}
这两种格式等价,可以交替使用。
例1:应用函数
#!/bin/bash
#shell function demo
function funct{
echo "step 2"
return
}
#Main program starts here</