0

I have question. If I open a tsv file in libre office (linux excel), I have every tab delimited string in each column. But if I use awk, I received only first part of string which are delimited by space.

F.E.: Libre office:

a     how much I need    0   b
b     0    0     a
c     0    15     c
d     It is really wierd  0  d

And If I use :

awk -v OFS="\t" '{print $2}' tsv_file

how
0
0
It

But I would like to recieve

how much I need
0
0
It is really wierd

All fields are filled by strings and numbers.

Thank you.

Vonton
  • 2,872
  • 4
  • 20
  • 27

1 Answers1

4

Use -F'\t' to tell awk that the input is tab-delimited. It will set FS to a tab. The OFS variable is the output field delimiter/separator.

$ awk -F'\t' '{ print $2 }' tsv_file
Kusalananda
  • 14,885
  • 3
  • 41
  • 52