Append to the previous line for a match

后端 未结 4 1217
隐瞒了意图╮
隐瞒了意图╮ 2021-01-23 09:34

can I use sed or awk to append to the previous line if a match is found ?

I have a file which has the format :

          INT32         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-23 09:44

    [shyam@localhost ~]$ perl -lne 's/^/\n/ if $.>1 && /^\d+/; printf "%s",$_' appendDateText.txt

    that will work

    i/p:

    06/12/2016 20:30 Test Test Test

    TestTest

    06/12/2019 20:30 abbs abcbcb abcbc

    06/11/2016 20:30 test test

    i123312331233123312331233123312331233123312331233Test

    06/12/2016 20:30 abc

    o/p:

    06/12/2016 20:30 Test Test TestTestTest

    06/12/2019 20:30 abbs abcbcb abcbc

    06/11/2016 20:30 test ##testi123312331233123312331233123312331233123312331233Test

提交回复
热议问题