Re: Getting a text file rid of all superfluous blank lines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2005-11-30 at 12:42 +0000, Paul Smith wrote: 
> On 11/30/05, Tim <ignored_mailbox@xxxxxxxxxxxx> wrote:
> $ more file1.txt
> word1
> 
> 
> 
> word2
> 
> word3
> $ more -s file1.txt > file2.txt
> $ more file2.txt
> word1
> 
> 
> 
> word2
> 
> word3
> $
> 
> Tim's way works partially, i.e., many blank lines are in effect
> erased, but some remain. I suspect that the left blank lines are not
> blank lines although they look like blank lines. Can one go further
> with deleting the left "false" blank lines?

I did it this way:

cat file1 | grep -v "^[ ]*$"

supposing some lines could have no blanks (regex=/^$/) or some spaces
(regex for any number of spaces=/[ ]*/) 

--
Rodolfo Alcazar - rodolfo.alcazar@xxxxxxxxxxxx
Netzmanager Padep, GTZ
591-70656800, -22417628, LA PAZ, BOLIVIA
http://otbits.blogspot.com
--
Murphy's Law of Thermodynamics:
Things get worse under pressure.




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux