Separate columns into different text files

Hi

I have large text file consisting of five columns. Sample of the file is give below:

ed    2-4   12.0    commons that they depended on.           
ed    3-1    12.0    Almost E, but  would be over.         ,       .
launch    4-1    implied    Failed configuration server: %s        : %s
ind12    2-3    manual    Aryans did statues or temples for deities.       

I need a script which will separate the last two columns into two different files - File-1.txt and File-2.txt. The columns are separated by a tab.

Thanks in advance. :slight_smile:

Do you mean ALL the columns before last go to File-1.txt and ALL last columns go to File-2.txt?

Can you post an example of desired output for File-1.txt and File-2.txt, based on the sample file you originally posted?

awk -F"\t" ' { print $(NF-1) > "File-1.txt"; print $NF > "File-2.txt" } ' Inputfile
1 Like