2

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
0

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.