- 论坛徽章:
- 771
|
回复 14# bikkuri
找了一上午,没找到怎么忽略输入中的\0的。
楼主看一一下下面这段,gawk外的其他awk
都是以\0为结束的。
Advanced Notes: RS = "\0" Is Not Portable
There are times when you might want to treat an entire data file as a single record. The only way to make this happen is to give RS a value that you know doesn't occur in the input file. This is hard to do in a general way, such that a program always works for arbitrary input files.
You might think that for text files, the NUL character, which consists of a character with all bits equal to zero, is a good value to use for RS in this case:
BEGIN { RS = "\0" } # whole file becomes one record?
gawk in fact accepts this, and uses the NUL character for the record separator. However, this usage is not portable to other awk implementations.
All other awk implementations(15) store strings internally as C-style strings. C strings use the NUL character as the string terminator. In effect, this means that `RS = "\0"' is the same as `RS = ""'. (d.c.)
The best way to treat a whole file as a single record is to simply read the file in, one record at a time, concatenating each record onto the end of the previous ones.
|
|