Splitting a file with lines separated by tabs into two files

awksedtext processing

How could I use something like sed to split a file into two so the file containing

eric    shwartz
david    snyder

where the 4 spaces between entries are actually tabs into two files such as:

file1:

eric
david

file2:

shwartz
snyder

So it puts everything after the tab on each line into another file.

Best Answer

A solution could be:

awk '{ print $1 > "file1"; print $2 > "file2"}' file 
Related Question