Ex:
Input file
******************
.WER
+ aaa bbb ccc
+ ddd eee
+ fff ggg hhh
******************
.SDF
+ zzz xxx yyy
+ iii
+ kkk lll
******************
.XCV
+ uuu vvv ggg
+ hhh qqq
+ rrr ttt jjj
******************
Desired Output:
******************
.WER aaa bbb ccc ddd eee fff ggg hhh
******************
.SDF zzz xxx yyy iii kkk lll
******************
.XCV uuu vvv ggg hhh qqq rrr ttt jjj
******************
I want to append line which matches pattern "+" to previous line and replace "+" with a space.
Can anyone solve this problem by using awk or sed (even grep) command?
I am a beginner in Linux. Please explain the details of the whole command line.
sedusesed 'H;1h;$!d;x;s/\n+//g'like explained in https://unix.stackexchange.com/questions/533277/how-do-i-process-the-whole-file-in-one-buffer-in-sed-without-gnu-z-option or you can't avoid a loop likesed -e :1 -e 'N;s/\n+//;t1' -e 'P;D'– Philippos Aug 28 '19 at 17:06-ztells sed toTreat the input as a set of lines, each terminated by a zero byte (the ASCII ‘NUL’ character) instead of a newline.(from the man page) so the\nat the end of the file should be treated the same as every other\n. The POSIX scripts you posted remove the final\nas expected, any idea why it doesn't get removed with the GNUsed -zversion? – Ed Morton Sep 03 '19 at 13:27