I am having some difficulty getting my SED script to work properly. It appears to only work on the first occurrence. I am basically a UNIX beginner - please bear with me.
Data file looks like this:
exec cics
end-exec.
exec cics
send map
end-exec.
exec cics
end-exec.
Actual output is as follows and appears to work correctly only on the first occurrence:
exec cics end-exec.
exec cics
send map
end-exec.
exec cics
end-exec.
Desired output should be as follows:
exec cics end-exec.
exec cics send map end-exec.
exec cics end-exec.
Everything starting with "exec cics" and ending with "end-exec" should be on one line with any newlines removed.
SED script is as follows:
/exec cics/,/end-exec/{
:a
N
$!ba
s/\n//
}
I had got the code within the curly braces from here: How can I replace a newline (\n) using sed?
My initial script did not have the :a;N;$!ba
. Can anyone see what I am missing or doing wrong?