Here is the solution in python:
def njoin(filename, outfn="", n=3, linesuffix=" "):
if not outfn:
outfn = filename + ".join"
with open(filename) as infh, open(outfn, "w") as outfh:
nline = 0
for line in infh:
if nline % n != n-1:
line = line.rstrip() + linesuffix
outfh.write(line)
nline += 1
In this case, you can use the following function:
njoin("/path/to/file", n=2, linesuffixe=":")
source
share