I have a special file with this kind of format :
title1 _1 texthere title2 _2 texthere
I would like all newlines starting with \"_\" to be
This might work for you (GNU sed):
sed ':a;N;s/\n_/ /;ta;P;D' file
This avoids slurping the file into memory.
or:
sed -e ':a' -e 'N' -e 's/\n_/ /' -e 'ta' -e 'P' -e 'D' file