2011-03-24 29 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