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

seofangfa shell学习笔记评论1,2661阅读模式

函数:

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

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

文章末尾固定信息

weinxin
我的微信
我的微信
微信扫一扫
 
seofangfa
  • 本文由 seofangfa 发表于 2015年9月4日04:17:43
  • 转载请务必保留本文链接:https://wp.fangfa.me/shell/shell-if-for-switch-select.html
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证