I have an awk script from this example :
awk '/START/{if (x) print x; x="";}{x=(!x)?$0:x","$0;}END{print x;}' file
Here is an example file with lines:
$ cat file START 1 2 3 4 5 end 6 7 START 1 2 3 end 5 6 7
Therefore, I need to stop concatenating when the destination string contains the word end , so the desired result is:
START,1,2,3,4,5,end START,1,2,3,end
source share