1

我有 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

我认为awkon OmniOSis nawk,但不确定:

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

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

4

0 回答 0