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

评论