1

Im trying to have some symple output, the issue is that I can't seem to set the spaces. I have to manually calculate what each variable will have. Is there a way to format table outputs better with echo?

This code

      echo """
      Datasets available to download are:
    
      Dataset   -   File Format
      ${dataset_one[6]}    -   ${dataset_one[5]}
      ${dataset_two[6]}  -   ${dataset_two[5]}
      ${dataset_three[6]}    -   ${dataset_three[5]}
    
      You currently have downloaded to hdfs the the following datasets:
      """

Returns:

  Dataset   -   File Format
  dataset1   -   csv
  ds2  -   csv
  datasnytaxi   -   parquet
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Gonzalo Etse
  • 123
  • 1
  • 7

2 Answers2

2

I think column -t is what you are looking for:

-t Determine the number of columns the input contains and create a table. Columns are delimited with whitespace, by default, or with the characters supplied using the -s option. Useful for pretty-printing displays.

chuso
  • 91
  • 5
0

Try using '\t' with echo command. you can also refer to Echo tab characters in bash script for how to use '\t' with echo in bash. alternative you can also try printf;