I have a file like the following:
a,b,c,d,e,f 1,2,3,4,5,6 7,8,9,0,1,2
I need to join the last two lines with a comma, like so:
The problem is that this is all inside a loop that will add two new lines to that file, say
a,b,c,d,e,f 1,2,3,4,5,6,7,8,9,0,1,2 0,9,8,7,6,5 4,3,2,1,0,9
And now I need to do the same to that last line for the file to end like
a,b,c,d,e,f 1,2,3,4,5,6,7,8,9,0,1,2 0,9,8,7,6,5,4,3,2,1,0,9
So, in only a few words, I need to replace the last new line of a text file with a comma, but only the last line, as lines are being added.
I've tried several things but they don't work. The last one was
sed '$!N;s/\n/,/' dna.data, but it applies to all lines with a newline.