Vijay
Vijay

Reputation: 67211

separate the single file into many based upon a column value

i have a file like this:

one vijay   three
two vijay   four
five chandu three

outputfile1

one vijay   three
two vijay   four

outputfile2

five chandu three

the file is split based upon the value of the second column.

i can do this in shell scripting.but i suppose its more simple in awk to do. how do i do it in awk?

Upvotes: 3

Views: 628

Answers (1)

kurumi
kurumi

Reputation: 25599

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

Upvotes: 10

Related Questions