【Shell编程基础第一部分】Shell里if/for/switch/select等流程控制以及Shell里的函数!

shell学习笔记1,2921字数 197阅读0分39秒阅读模式

函数:

如果你写过比较复杂的脚本,就会发现可能在几个地方使用了相同的代码,这时如果用上函数,会方便很多。函数的大致样子如下:

functionname()
{
# inside the body $1 is the first argument given to the function
# $2 the second ...
body
}

示例代码:

#!/bin/sh
himi()
{
    echo "Function is ok"
    exit 0
}
himi

 最后更新:2015-9-13
  • 本文由 asdfasd 发表于 2015-09-0404:17:43
  • 转载请务必保留本文链接:http://wp.fangfa.me/shell/shell-if-for-switch-select.html