1

I'm trying to learn about sed, grep and awk, and I'm facing the folowing problem: I have the folowing log after use sed to get all lines between two patterns (START and END):

START
tag: text info text text info text
    text info texttext info text
    text info texttext info text
    text info texttext info text

other_tag: text info text text info text
    text info text text info text text info text
    text info text text info text text info text
END
START
tag: text info text text info text
    text info text text info text
    text info text text info text
other_tag: text info text text info text
    text info text text info text text info text
    text info text text info text text info text
END

I would like to merge all lines to their parent, removing the starting [tab], like that:

START
tag: text info text text info text text info text text info text text info text text info text text info text text info text
other_tag: text info text text info text text info text text info text text info text text info text text info text text info text
END
START
tag: text info text text info text text info text text info text text info text text info text
other_tag: text info text text info text text info text text info text text info text text info text text info text text info text
END

Could anyone help me? Thanks!

0

You might should go on using sed. Use N could append the next line of input into the pattern space, then you can match the \n between two line.

You can refer to:

sed ':a; N; $!b a; s/\n\s\{1,\}/ /g'
  • thanks a lot. It works perfectly! I'm still trainning sed reading and practicing lots of tutorials! thanks! – Nenhum Mail Jul 12 '17 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.