file1
looks like
# dsd
# dsd
1,2,5
2,3,5
1,2,5
2,3,5
3,4,5
3,4,5
file2
looks like
# s
1,2
1,2
I want to merge them to get
# dsd
# dsd
1,2,5,1,2
2,3,5,1,2
1,2,5,,
2,3,5,,
3,4,5,,
3,4,5,,
That is I want to keep the comment lines #
from the first file after the comment lines, I want to paste columns from the second file, padding them to the column length of the first file. If there are any comment lines in the second file, ignore them.
I started with:
paste $(grep -v '^#' file1) file2
but I get bash: /usr/bin/paste: Argument list too long
I guess this would be a job for awk
but I am only familiar with single file processing and I have only found examples that deal with the same length files. Is there an easy way or one needs to go to longer bash
script or python
et al.?