Sed remove end of line for specific lines

awksedtext processing

I'm trying to find the sed command to remove the end of the line (meaning, get the next line to the current), but only if line starts with the string NOTOK.

example input:

   NOTOK something detected
        details are                : some info

output should be:

NOTOK something detected        details are                : some info

Best Answer

With awk:

awk '$1 == "NOTOK" {printf "%s", $0; next} 1' file
Related Question