shell下function报错

来源:互联网 发布:淘宝订单数据 编辑:程序博客网 时间:2024/06/05 22:48


我输入最简单的function函数:
#!/bin/bash
#hello-fun
function hello()
{
echo "hello,today is `date`"
return 1
}

提示以下错误:
ymj@ymj-laptop:~/scripts$ sh hello_function.sh
hello_function.sh: 3: Syntax error: "(" unexpected


帮你修改了一下,下面是正确的结果

CODE:
#!/bin/bash
#hello-fun
function hello()
{
echo "hello,today is `date`"
return 1
}
hello

运行结果如下:
CODE:
hello,today is 2010年 10月 04日 星期一 11:57:57 CST