Computing.Net > Forums > Unix > Remove blank lines from file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Remove blank lines from file

Reply to Message Icon

Name: Nick
Date: September 25, 2002 at 10:37:47 Pacific
OS: Unix
CPU/Ram: 256
Comment:

What is the command to remove blank lines from a file.

Example of the file:
line1
line2

line3
line4



Sponsored Link
Ads by Google

Response Number 1
Name: ASB
Date: September 25, 2002 at 10:58:09 Pacific
Reply:

Try:

sed "/^$/d" input_file > output_file
mv output input

or

grep -v "^$" input_file > output_file
mv output input


0

Response Number 2
Name: Nick
Date: September 25, 2002 at 12:42:13 Pacific
Reply:

Hi ASB,

Your script works. Thanks.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


calculation file size on aix



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Remove blank lines from file

Removing blank lines www.computing.net/answers/unix/removing-blank-lines/5139.html

to remove duplicate lines from file www.computing.net/answers/unix/to-remove-duplicate-lines-from-file/7011.html

removing specific line from file www.computing.net/answers/unix/removing-specific-line-from-file/5042.html