为什么命令只能用于gawk?

时间:2015-04-28 08:23:49

标签: awk gawk nawk opensolaris omnios

我有2个主机:一个正在运行Linux,而另一个正在运行OmniOS

awk上的Linuxgawk

[root@localhost ~]# which awk
/bin/awk
[root@localhost ~]# ls -lt /bin/awk
lrwxrwxrwx. 1 root root 4 Jan 22  2014 /bin/awk -> gawk

运行以下命令即可:

[root@localhost  ~]# awk 'function print_name_and_age(name, age) { print name" is "age" old" } {print_name_and_age($1, $2)}'
Mark 12
Mark is 12 old

我认为awk上的OmniOSnawk,但不确定:

root@localhost:/root# which awk
/usr/bin/awk
root@localhost:/root# ls -lt /usr/bin/awk
-r-xr-xr-x   2 root     bin        90664 Apr  3 01:17 /usr/bin/awk
root@localhost:/root# awk
awk: Usage: awk [-Fc] [-f source | 'cmds'] [files]

但执行相同的命令是错误:

root@localhost:/root# awk 'function print_name_and_age(name, age) { print name" is "age" old" } {print_name_and_age($1, $2)}'
awk: syntax error near line 1
awk: bailing out near line 1

我无法找出根本原因,任何人都可以提供任何线索吗?

0 个答案:

没有答案