I have three files of varying lengths and different number of columns. How can I paste all three with all columns aligned?
File1
----
123
File2
----
234
345
678
File3
----
456
789
Output should look like:
123 234 456
345 789
678
Using paste messes up the formatting and gives output as:
123 234 456
345 789
678
Please advise. Thanks
-Vin
alister
February 27, 2014, 11:55am
2
I advise you to use code tags, because both of your samples appear identical without them. Also, you probably made a mistake and typed 678 in place of 789 at some point.
Regards,
Alister
Thanks for the tip. Fixed.
What operating system are you using? Please show us the exact command that you used?
When I try the command:
paste File1 File2 File3
with the data you showed us for those three files, I get the output:
123 234 456
345 789
678
or (with \t replacing tab characters):
123\t234\t456
\t345\t789
\t678\t
which seems to match what you said you wanted.
The OS is RHEL. The output is as you have listed from command line. The column alignment is messed up when paste is used in a script.
What you are saying doesn't make sense. We must be missing some context.
Please post your script and show us where the output from paste has messed up column alignment.
What version of red hat? what shell
Appears to work fine in bash/zsh for me.
$ paste 1 2 3
123 234 456
345 789
678