I have a C program that outputs two columns, utterly misaligned. The reason for the misalignment is lengths of words in the first column are very different.
I have an output file opened in vi. How do I quickly align these two columns? I am fine with using awk, perl, sed, and not just vi (7.2) toolset. Also, can we have a generic solution for files with more than two columns?
Here is sample file
column1 column2
------- -------
sdfsdfsddfsdfsdfsdfsd 343r5
dfgdfgdf 234
gdfgdfgdfgdfgf 645
Presumably you are using
printfto output the columns in the first place. You can use extra modifiers in your format string to make sure things get aligned.To give a more in depth example:
This would print three columns like this: