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

后端 未结 14 2365
难免孤独
难免孤独 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:41

    I take it that you'll probably want to remove lines that only have whitespace.

    That can be done with:

    sed /^[:space:]*$/d FILE
    

提交回复
热议问题