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

前端 未结 8 1077
迷失自我
迷失自我 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:40

    perl -pe 's/foo\n/foo\t/g' temp2.txt
    

    below is the test.

    243> cat temp2.txt 
    foo
    bar bar bar bar some text 
    pearl[ncm_o12.2_int_x86.@2].244> perl -pe 's/foo\n/foo\t/g' temp2.txt
    foo     bar bar bar bar some text 
    

提交回复
热议问题