0

This question already has an answer here:

I have a text file with a lot of blank lines that I want to remove like:

aaa

bbb


ccc

I would like to get:

aaa
bbb
ccc

At the moment I am trying:

LANG=C sed -E '/^\n|^\r|^\r\n|^\n\r/d' file

I should say I am using OSX. I have tried quite a few things and can't figure out what I'm doing wrong.

I have already tried searching for \r character

marked as duplicate by GAD3R, Rui F Ribeiro, Kusalananda, Community Aug 21 '17 at 19:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @8bittree I searched everywhere to find an answer (most similar questions didn't help) but you managed to find one I didn't see. I have tried it and it worked. Thanks very much! – user3891532 Aug 21 '17 at 19:32
0

Try this:

sed -i '/^$/d' file.txt

Not the answer you're looking for? Browse other questions tagged or ask your own question.