【发布时间】:2014-08-15 08:07:13
【问题描述】:
我有一个制表符分隔的文件:
xyz
abc foo bar
hello world
lmn opq rst
我想提取正好有 3 个标签的行并实现:
abc foo bar
lmn opq rst
我一直在用python做:
fout = ('outfile', 'w')
with open('infile', 'r') as fin:
for line in fin:
if line.count('\t') == 3:
print>>fout, line
unix/bash 的实现方式是什么?
【问题讨论】:
-
你显示的输出是用空格分隔的?