How can I replace multiple empty lines with a single empty line in bash?

后端 未结 14 2369
难免孤独
难免孤独 2020-12-13 06:14

I have a file that contains:

something



something else

something else again

I need a bash command, sed/grep w.e that will produce the fo

14条回答
  •  佛祖请我去吃肉
    2020-12-13 06:32

    I just solved this problem by sed. Even if this is a 7 years old question, someone may can here for help, so I am writing my solution by sed here:

    sed 'N;/^\n$/D;P;D;'
    

提交回复
热议问题