然后我用同一条awk命令将6行的文本折叠成两行,其中对b文件可以得到期望的结果,但是对a文件的操作却失败了!
[root@betactvdh:/tmp]# cat a|awk '{for(i>0;i<=NR;i++)a=$0}END{for(j=0;3*j+1<i;j++){printf"|";for(k=1;k<=3;k++)printf a[3*j+k]"|";printf"\n"}}'
|1|awk: cmd. line:1: (FILENAME=- FNR=6) fatal: not enough arguments to satisfy format string
`2% o|'
^ ran out for this one
[root@betactvdh:/tmp]# cat b|awk '{for(i>0;i<=NR;i++)a=$0}END{for(j=0;3*j+1<i;j++){printf"|";for(k=1;k<=3;k++)printf a[3*j+k]"|";printf"\n"}}'
|1|2% A|3|
|4|5|6|
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@betactvdh:/tmp]#