gc a.txt|%{$_.split()[0]}
基本是这样,根据文本格式可能需要调试和稍作修改。
看一下例子吧:
awk以制表符为分隔符,输出第一列:
awk -F '\t' '{print $1}' your_file
python读入文件,将每行用strip()去除字符串结尾的"\t",再用split("\t")以制表符为分隔符将该行的每一列内容放入到列表ls中,再操作列表ls就可以了:
for l in file("your_file"):
ls = l.strip().split("\t")
print ls[0]