Removing new line after a particular text via bash/awk/sed/perl

前端 未结 8 1043
迷失自我
迷失自我 2021-01-02 00:22

I would like to remove all the newline character that occurs after a partiular string and replace it with a tab space. Say for instance my sample.txt is as follows



        
8条回答
  •  悲&欢浪女
    2021-01-02 00:34

    Here is how:

    cat input.txt | sed ':a;N;$!ba;s/foo\n/foo\t/g'
    

    More about why simple sed 's/foo\n/foo\t/g' does not work here: http://linuxtopia.org/online_books/linux_tool_guides/the_sed_faq/sedfaq5_009.html

提交回复
热议问题