5

I am using this awk command to print out certain columns of a file

awk '{print $1,$2,$3,$5,log($11),$12}' inputfile > outputfile

The inputfile is tab-delimited, and the outputfile is space-delimited. I need the outputfile to be tab-delimited as well. I tried this, but this still gives me a space-delimited file:

awk 'BEGIN{FS="\t"}{print $1,$2,$3,$5,log($11),$12}' inputfile > outputfile

What am I doing wrong? Many thanks!

Abdel
  • 5,826
  • 12
  • 56
  • 77

1 Answers1

12

I think you want BEGIN { OFS="\t" }, to set only the output field separator.

piojo
  • 6,351
  • 1
  • 26
  • 36