Comment 2 for bug 1644703

Revision history for this message
Assaf Gordon (agn1) wrote :

Hello,

(I'm datamash's developer).

This is not a bug but intended operation: the 'scores.txt' is a tab-separated file.
datamash maintains the tabs as in the input - this is how it should be.

The output is not aligned on the terminal because some lines contain long text (longer than 8 characters) which then push the tab output to the next 'column'.

It is equivalent to the following situation:

  $ printf "a\t1\nvery-long-text\t2\n"
  a 1
  very-long-text 2

You can observe this with 'cat -A' (which displays tabs as '^I'):

  $ datamash -g 2 min 3 max 3 < scores.txt | cat -A
  Arts^I46^I88$
  Business^I79^I94$
  Health-Medicine^I72^I100$
  Social-Sciences^I27^I90$
  Life-Sciences^I14^I91$
  Engineering^I39^I99$

If you want to align tab-separated values properly on the screen, use 'expand':

  $ datamash -g 2 min 3 max 3 < scores.txt | expand -t20,30
  Arts 46 88
  Business 79 94
  Health-Medicine 72 100
  Social-Sciences 27 90
  Life-Sciences 14 91
  Engineering 39 99

regards,
 - assaf