- 论坛徽章:
- 0
|
不过waker用的应该是gawk,gawk是可以把RS定义成多个字符的。
这是fc4上的测试结果:
- [~]$
- [~]$ cat foo.c
- /* sldfjsla;fjaslfsd;fjsa;f
- sdfj;asldj / ;lsjf;aslfj
- ;sdjf;sdljfl j*/
- int a=c/d;
- int b=a*k;
- [~]$
- [~]$
- [~]$
- [~]$ awk 'BEGIN{RS="/\\*|\\*/"} NR%2' foo.c
- int a=c/d;
- int b=a*k;
- [~]$
- [~]$ awk --version
- GNU Awk 3.1.4
- Copyright (C) 1989, 1991-2003 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 2 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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- [~]$
- [~]$
复制代码
这是fb6.1上的测试结果:
- [~]$
- [~]$ cat foo.c
- /* ldfjsla;fjaslfsd;fjsa;f
- sdfj;asldj / ;lsjf;aslfj
- ;sdjf;sdljfl j*/
- int a=c/d;
- int b=a*k;
- [~]$
- [~]$
- [~]$ awk 'BEGIN{RS="/\*|\*/"} NR%2' foo.c
- ;lsjf;aslfj
- ;sdjf;sdljfl j*
- d;
- int b=a*k;
- [~]$
- [~]$
- [~]$ awk -V
- awk version 20050424 (FreeBSD)
- [~]$
复制代码 |
|