I've got a .txt file like this:

enter image description here

I want to get it like this:

enter image description here

I'm thinking I need to replace /(beginning of line)(new line character)/.

  • 3
    grep -v '^$' ? – Stephen Harris Aug 17 '16 at 1:32
  • 1
    Also see Please don't post images of text – Zachary Brady Aug 17 '16 at 1:52
  • Why are you trying to reopen the question without changing its contents, especially considering it already has an answer and it's a duplicate? – Julie Pelletier Aug 17 '16 at 6:16
  • @JuliePelletier, what? I didn't try to reopen it. – Forwarding Aug 17 '16 at 17:49
  • Maybe it got a reopen request because of a minor change you did to it. – Julie Pelletier Aug 17 '16 at 18:30

Please don't post pictures of text; copy and paste from the terminal into the question.

There are several ways to filter out blank lines. Two of the simplest would be as follows.

With grep:

grep -v '^$' /path/to/input > /path/to/output

With sed:

sed '/^$/d' /path/to/input > /path/to/output
sed --in-place '/^$/d' /path/to/input # modify the file rather than creating a new one

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