【发布时间】:2015-06-22 15:16:40
【问题描述】:
我不理解以下行为:
这是一个文本文件:
example.txt
12345 4321 hello hello this is a test blobb
14324 2131 another test , incoming ! blubb
52341 1231 last test now shutting down bla
...
它由 x 行文本组成,每行 4 个制表符分隔的列。我只需要前三个,所以我使用了awk(第一次):
awk '{FS="\t"; OFS="\t"; print $1,$2,$3}' < example.txt > excerpt.txt
结果是这样的:
excerpt.txt
12345 4321 hello
14324 2131 another test , incoming !
52341 1231 last test now shutting down
...
第一个条目不包含完整的第三列,打印$1,$2,$3,$4 会为第一行提供12345 4321 hello hello。因此,显然它在空格处分隔(在第一个和第二个 hello 之后),而不是在制表符处。我检查了是否有标签潜入其中,但事实并非如此:
我觉得这很令人困惑,因为它适用于所有其他行。
【问题讨论】: