I want to paste two files together, but with vertical alignment after a section delimiter line ::. Here’s what I mean.
Contents of file1:
Apple
Banana
Carrot
::
Durian
Contents of file2:
Energy
Flight
::
Gravity
Heartbreak
Desired output:
Apple Energy
Banana Flight
Carrot
::
Durian Gravity
Heartbreak
So far I know paste will almost do what I want (without the nice vertical alignment); another option is to split file1 and file2 into multiple files, then concatenate the results together, but I want to avoid that if I can. How can I do this?
I don’t strictly need a solution that uses paste. Anything that works works!
man columnfor something that provides this feature. I'm not clear howpastecan deal with re-alignment after the::group separator lines -- we might be intoawkterritory here.columncan't insert blank fields to adjust alignment vertically.::parts before the paste. Also, I recently had a battle withcolumnbecause it treats multiple separators as one, so fails to columnise empty fields. You need a placeholder for empty fields. Henceawkmay be the easiest solution.columnproblem described, and my solution in awk for a similar problem.https://unix.stackexchange.com/questions/724928/text-processing-rows-to-columns-for-a-block-of-lines-awk/725043#725043awksolution. Should I edit this question to clarify that I’m not strictly asking for apastesolution, or is that clear already?