Awk to output table or excel-like columns in linux terminal?

I make a long channel ending ...| awk '{print $5"\t\t" $3"\t"$4}' ...| awk '{print $5"\t\t" $3"\t"$4}' in a Linux terminal. Columns are supplemented with tabs. The first column entries have a different number of characters, so the results of the second column are not completely vertical. How to make a table perfect?

enter image description here

+8
bash terminal awk multiple-columns
source share
2 answers

try passing the result to the -t column:

 ...| awk '{print $5"\t\t" $3"\t"$4}'|column -t 

hope this helps

+23
source share

if your fields are tabbed, the next line of the script can print a table with cell borders

 sed -e 's/\t/_|/g' table.txt | column -t -s '_' | awk '1;!(NR%1){print "-----------------------------------------------------------------------";}' Description |value |Comment ----------------------------------------------------------------------- Internal |322 | ----------------------------------------------------------------------- External |42515 | ----------------------------------------------------------------------- 
+6
source share

All Articles