2

I have two lists of words:

$ head -n 15 words.txt > list1
$ tail -n 15 words.txt > list2

I paste them together into columns:

$ paste list1 list2

The result is this, with tabs between the columns:

2       Zwiebel
1080    zwieselite
&c      Zwingle
10-point        Zwingli
10th    Zwinglian
11-point        Zwinglianism
12-point        Zwinglianist
16-point        zwitter
18-point        zwitterion
1st     zwitterionic
2,4,5-t Zwolle
2,4-d   Zworykin
20-point        ZZ
2D      zZt
2nd     ZZZ

I would like this instead, where there are more tabs between the columns on certain lines:

2               Zwiebel
1080            zwieselite
&c              Zwingle
10-point        Zwingli
10th            Zwinglian
11-point        Zwinglianism
12-point        Zwinglianist
16-point        zwitter
18-point        zwitterion
1st             zwitterionic
2,4,5-t         Zwolle
2,4-d           Zworykin
20-point        ZZ
2D              zZt
2nd             ZZZ

How do I do this?

paradroid
  • 1,203

1 Answers1

4

Either pipe the result through column -t:

paste list1 list2 | column -t

or use pr with the -m (merge) option:

pr -Tm list1 list2

Note that the latter may truncate columns if the output exceeds the current PAGE_WIDTH (by default, 72 characters) - if that becomes an issue you may need to increase the page width using -w

steeldriver
  • 81,074