- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2012-09-26 13:15 编辑
@chichushanren
@rdcwayx
awk version issue
man gawk
As of version 3.1.5, gawk is multibyte aware. This means that index(),
length(), substr() and match() all work in terms of characters, not
bytes.
awk use other way to identify, or use perl command easily
$ gawk '{N=split($0,a,"");for(n=1;n<=N;n++)print length(a[n]),a[n]}' test.txt
1 a
1 s
1 d
1 f
1 王
1 小
1 明
1 a
1 b
1 c
$ gawk '{N=split($0,a,"");for(n=1;n<=N;n++)if(a[n]~/[a-z]/)print "w="a[n];else print "CN="a[n]}' test.txt
w=a
w=s
w=d
w=f
CN=王
CN=小
CN=明
w=a
w=b
w=c
|
|