Wednesday, September 12, 2007

squeezed multiple blank lines into single line

Here's a way to squeeze multiple blank lines of a text file into a single line using more.

# 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 those multiple blank lines using more from command line would be

# more -s 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 tex
t file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy