Using awk (or sed) to remove newlines based on first character of next line

前端 未结 5 2052
陌清茗
陌清茗 2021-02-15 14:23

here\'s my situation: I had a big text file that I wanted to pull certain information from. I used sed to pull all the relevant information based on regexp\'s, but each \"piece\

5条回答
  •  终归单人心
    2021-02-15 14:38

    $ perl -0pe 's/\n,/,/g' < test.dat
    92831,499,000,0644321
    79217,999,000,5417178,PK91622,PK90755
    

    Translation: Read in bulk without line separation, swap out each comma following a newline with just a comma.

    Shortest code here!

提交回复
热议问题