I have a file with dynamic length columns (four) separated with tabs (a column can have have spaces)
COL1 COL2 COL2 COL2 COL3 COL3 COL4
COL1 COL2 COL2 COL3 COL4 COL4
COL1 COL1 COL2 COL2 COL3 COL4 COL4 COL4
I 'd like to format it dynamically with printf in awk? I can format it with fixed adjustments:
$ awk 'BEGIN {FS="\t"}; {printf "%-10s %-10s %-15s %-15s\n", $1,$3,$4,$2}' test
COL1 COL3 COL3 COL4 COL2 COL2 COL2
COL1 COL3 COL4 COL4 COL2 COL2
COL1 COL1 COL3 COL4 COL4 COL4 COL2 COL2
column -t file
? – user000001 Feb 9 '18 at 17:06