Read input write multply output with creteria

Hi All

Please Help

Read input write multply output with creteria

Exemple i have file

abc 111 444
abc 111 444
def 111 444
def111 444
bbb 111 444
bbb 111 444

i would need write 3 files pos 1-3 is the Criteria

output would be file1 contains abc file2 def file3 bbb

Thank you

Did you consider the csplit command?

EDIT: Looking at your problem a secong time, csplit might NOT be the tool of choice. Try instead

awk '{TMP = substr ($0, 1, 3); if (!(TMP in FN)) FN[TMP] = ++CNT; print TMP  > ("file" FN[TMP])}' file

Thank you

it will create 3 files?

It will create as many files as different criteria are present in the input file. Should these become more than ther OPEN_MAX system configuration parameter, append ( >> ) to the respective output files and close after each write.