How can I align the columns of tables in Bash?

前端 未结 9 1998
一个人的身影
一个人的身影 2020-12-02 08:25

I\'d like to output a table format text. What I tried to do was echo the elements of an array with \'\\t\', but it was misaligned.

My code

for((i=0;i         


        
9条回答
  •  遥遥无期
    2020-12-02 08:54

    To have the exact same output as you need, you need to format the file like that :

    a very long string..........\t     112232432\t     anotherfield\n
    a smaller string\t      123124343\t     anotherfield\n
    

    And then using :

    $ column -t -s $'\t' FILE
    a very long string..........  112232432  anotherfield
    a smaller string              123124343  anotherfield
    

提交回复
热议问题