Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How to remove blank lines in .txt files

Using sed, how can I delete all blank lines?

Input file:

Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA 83755:11/12/56:20300

Betty Boop:245-836-8357:635 Cutesy Lane, Hollywood, CA 91464:6/23/23:14500

Igor Chevsky:385-375-8395:3567 Populus Place, Caldwell, NJ 23875:6/18/68:23400

Norma Corder:397-857-2735:74 Pine Street, Dearborn, MI 23874:3/28/45:245500

Jennifer Cowan:548-834-2348:583 Laurel Ave., Kingsville, TX 83745:10/1/35:58900

share|improve this question

marked as duplicate by slhck Oct 17 '12 at 17:18

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.

up vote 5 down vote accepted

Removing empty lines from input-file with sed can be done like this:

sed -i '/^$/d' input-file

The -i switch tells sed to do its modifications directly in place (without creating a new file), ^ is the symbol for the beginning of the line, $ is the symbol for the end of the line and d activates the delete action.

Thus, the command above says Match all lines in input-file with nothing between the beginning and the end of the line and delete them from the file directly.

share|improve this answer
Works great! Thanks for the explanation ... – Steve Oct 8 '12 at 21:19

Not the answer you're looking for? Browse other questions tagged .