2011-03-24 32 views
3

我有一个这样的文件:基于列的值的单个文件分离成许多

one vijay three 
two vijay four 
five chandu three 

outputfile1

one vijay three 
two vijay four 

outputfile2

five chandu three 

文件是基于分裂第二列的值。

我可以在shell脚本中做到这一点,但我想它在awk中做得更简单。 我该如何在awk中做到这一点?

回答

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