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

Vij*_*jay 3 bash shell awk

我有这样的文件:

one vijay   three
two vijay   four
five chandu three
Run Code Online (Sandbox Code Playgroud)

outputfile1

one vijay   three
two vijay   four
Run Code Online (Sandbox Code Playgroud)

outputfile2

five chandu three
Run Code Online (Sandbox Code Playgroud)

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

我可以在shell脚本中执行此操作.但我认为它在awk中更简单.我怎么用awk做的?

kur*_*umi 10

awk '{print $0>$2".txt"}' file
Run Code Online (Sandbox Code Playgroud)