Well, just popped out from my mind based from privious linux blog entry.
Have you ever tried editing a thousand lines of configuration file and 70% of the lines were commented? Yes, you can filter out the commented lines using grep, but what about totally removing multiple blank lines between each config line?
Here's a quick way on how to remove all blank lines from a file using strings linux command.
A sample readable text file.
# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is a long line of words that is useless for now.This file is an example of human readable text file.
I am going to paste this file into my Linux SysAd blog! This is a long line of words that is useless for now.This file is an example of human readable text file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To squeezed out and remove multiple or all blank lines from the text file using string linux command would be like so
# strings testfile.txt
EDITED:
# strings -n 1 testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a long line of words that is useless for now.This file is an example of human readable text file.
I am going to paste this file into my Linux SysAd blog! This is a long line of words that is useless for now.This file is an example of human readable text file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
EDITED:
# strings -n 1 testfile.txt
HTH
No comments:
Post a Comment
Thanks for the comment and for peeping into my blogspot. Hope you enjoy your reading them.
If you wish to receive posts updates, you can subscribe directly from this link:
http://feeds.feedburner.com/VertitosBlogspot
using any RSS reader or even Google Reader.
Again, appreciate your site visits.
Cheers then
VeRTiTO
Email: vertito@gmail.com