- 论坛徽章:
- 18
|
请问为什么第一条命令可以得到结果,而后面三条命令都报错了?
[root@jubuntu:~]$ /usr/bin/awk 'BEGIN{x[1]=foo;x[2]=bar;print length(x);}'
2
[root@jubuntu:~]$ awk 'BEGIN{x[1]=foo;x[2]=bar;print length(x);}'
awk: cmd. line:1: fatal: length: received array argument
[root@jubuntu:~]$ awk --posix 'BEGIN{x[1]=foo;x[2]=bar;print length(x);}'
awk: cmd. line:1: fatal: length: received array argument
[root@jubuntu:~]$ /usr/bin/awk --posix 'BEGIN{x[1]=foo;x[2]=bar;print length(x);}'
awk: cmd. line:1: fatal: length: received array argument
[root@jubuntu:~]$ /usr/bin/awk --version
GNU Awk 4.1.4, API: 1.1 (GNU MPFR 4.0.1, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2016 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
[root@jubuntu:~]$ awk --version
GNU Awk 4.1.4, API: 1.1 (GNU MPFR 4.0.1, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2016 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
[root@jubuntu:~]$
|
|