How can I remove a line-feed/newline BEFORE a pattern using sed

前端 未结 5 1986
悲哀的现实
悲哀的现实 2021-01-02 17:34

The title already states it:

I want to use some linux one liner (e.g. sed)

to transform

Anytext
{

into

Anyt         


        
5条回答
  •  轮回少年
    2021-01-02 18:23

    Using awk

    cat file
    one
    Anytext
    {
    two
    three
    {
    four
    five
    {
    

    awk '{printf (!/^{/&&NR>1?RS:x)"%s",$0} END {print ""}' file
    one
    Anytext{
    two
    three{
    four
    five{
    

提交回复
热议问题