根据列值将单个文件分割成多个。

3

i have a file like this:

one vijay   three
two vijay   four
five chandu three

输出文件1

one vijay   three
two vijay   four

输出文件2

five chandu three

根据第二列的值拆分文件。

我可以在shell脚本中完成这个操作,但我认为使用awk更简单。 如何在awk中完成此操作?

1个回答

10
awk '{print $0>$2".txt"}' file

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接