awk - Why does the command only work in gawk? -


i have 2 hosts: 1 running linux, while other omnios.

the awk on linux gawk:

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

and running following command ok:

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

i think awk on omnios nawk, not sure:

root@localhost:/root# 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] 

but executing same command error:

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

i can't figure out root cause, give clues?