I had a file with contents as below, with three columns which needed to be formatted/aligned:
ABCD XYZAB 1234
PQRSTUV STU 9113
LMN OPRQM 8966
I came up with the following shell script:
while read -r col1 col2 col3;
do printf "%s%-80s%-80s\n" "$col1" "$col2" "$col3";
done <spaced-define.txt > tabbed-define.txt
and managed to get them aligned like this, with spaces in between:
ABCD <SPACES> XYZAB <SPACES> 1234
PQRSTUV <SPACES> STU <SPACES> 9113
LMN <SPACES> OPRQM <SPACES> 8966
What I am unable to figure out is how to achieve the same alignment using tabs instead of spaces ?
ABCD <TABS> XYZAB <TABS> 1234
PQRSTUV <TABS> STU <TABS> 9113
LMN <TABS> OPRQM <TABS> 8966