Computing.Net > Forums > Unix > Blank lines in 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.

Blank lines in File

Reply to Message Icon

Name: Ravi Choudhary
Date: August 17, 2001 at 13:01:37 Pacific
Comment:

I have very big file, which contains almost alternate blank lines. Can anybody suggest me how to delete those lines? I don't want to go on individual lines to delete it.



Sponsored Link
Ads by Google

Response Number 1
Name: Grant
Date: August 17, 2001 at 20:26:23 Pacific
Reply:

Try grep -v "^$" file_name This should tell grep to search for all lines not matching a line with nothing between the start ^ and the finish $


0

Response Number 2
Name: James Boothe
Date: August 27, 2001 at 15:28:44 Pacific
Reply:

and redirect your output to a new file:
grep -v "^$" oldfile > newfile
That grep command will eliminate null lines, but to eliminate both null lines and lines containing only whitespace, do:
awk 'NF>0' oldfile > newfile


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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: Blank lines in File

remove top line in file www.computing.net/answers/unix/remove-top-line-in-file/4769.html

Remove blank lines from file www.computing.net/answers/unix/remove-blank-lines-from-file/3887.html

store a line from file in variable www.computing.net/answers/unix/store-a-line-from-file-in-variable/4659.html