One - One Code All

Blog Content

shell文件里函数和执行时报错Syntax error: "(" unexpected

Linux-Mac   2008-04-11 22:08:49

shell文件里函数和执行时报错Syntax error: "(" unexpected。


$ sh  test.sh 执行时报错,提示:Syntax error: "(" unexpected。


原因:

sh被重定向到dash,因此,如果执行./test.sh,则使用的是dash


解决:

执行 bash example.sh,

或者,将脚本第一行改为
#!/bin/bash,执行./test.sh。


上一篇:centos下查看云服务器本机公网IP
下一篇:imp的用法

The minute you think of giving up, think of the reason why you held on so long.