I'm trying to join two csv files, sorted, and with tab delimiter.

I'm new to the join command, so I'm not too sure about how to use it, but it seems to be replacing every tab in the files with spaces (messing up the alignment).

The command I'm using is:

join -1 5 -2 2 -t $'\t' -o $order --header file1.csv file2.csv | 
column -t > result.csv

In the first file, the data is sorted according to the 5th column, and the 2nd column in the second file. The variable $order is a simple string containing the different columns '1.1 1.2 1.3' etc. (28 of them). The delimiter I'm using comes from SE.

Do you know where this comes from?

  • If the $order var is space separated, (rather than comma separated), it needs to be quoted.
    – agc
    Jun 14, 2019 at 10:37

2 Answers 2


The character used by join with -t as delimiter will be used for both input and output.

The issue is the post-processing step, column -t, that you use. It will replace tabs with the appropriate number of spaces to align the columns nicely. If you want to preserve the tabs in the output of join, don't pass the data through column -t.

Only use column -t for final (visual) presentation of tabulated data.


It is because column -t, with the table mode automatically determines the column width and creates a readable table output and delimits output with spaces and not tabs. To do this explicitly using column, use its output delimiter set flag with -o

join -1 5 -2 2 -t $'\t' -o $order --header file1.csv file2.csv | 
column -o '\t' > result.csv
  • thanks man, just unstuck me there
    – olirwin
    Jun 14, 2019 at 11:13
  • Why use column at all for this? Isn't it basically doing a cat here?
    – Ed Morton
    Jun 15, 2019 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.