Skip to main content
Retag
Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77
Source Link

Problems awking column from txt file

I have a txt file (input.txt) that looks like this:

A_Karitiana-4.DG        Ignore_Karitiana(discovery).DG
A_French-4.DG   Ignore_French(discovery).DG
A_Dinka-4.DG    Dinka.DG
A_Dai-5.DG      Dai.DG
S_Dai-2.DG      Dai.DG
B_Dai-4.DG      Dai.DG
S_Dai-3.DG      Dai.DG
S_Dai-1.DG      Dai.DG

I need to create a new txt file (output.txt) that contains only the first column of input.txt. So output.txt must look like this:

A_Karitiana-4.DG        
A_French-4.DG   
A_Dinka-4.DG    
A_Dai-5.DG      
S_Dai-2.DG      
B_Dai-4.DG      
S_Dai-3.DG      
S_Dai-1.DG      

I've tried with this command:

awk '$1' input.txt > output.txt

and also with this:

awk -F' ' '$1' input.txt > output.txt

but both of them create an output.txt file that looks exactly the same as input.txt.

I suppose it's a matter of delimiter, but I can't figure out how to fix this.