[CS-FSLUG] An easy way to remove blank lines?
Josiah Ritchie
jritchie at bible.edu
Fri Sep 9 12:05:06 CDT 2005
In a regular expression commonly used in a sed, grep, awk or shell
script use ^ for a beginning of line and $ for the end of line
The quick and dirty way to do this would be this:
grep -v ^$ source.html > new.html
Theoretically you could do grep -v ^$ source.html > source.html to
overwrite it, but this is always considered a bad idea as nasty things
happen if you don't have enough ram to spool the file. In practice, I
find it usually works fine. Just make sure you have a backup of the
original files.
With Ed's looking for 2 end of line's you may run into multiple blank
lines and get an odd response. I don't know though as I haven't tried
it.
I bet you find something equivalent to this burried in JD's link.
I'd like to know how to do this is sed. You inspired me to play with it
for about 3 minutes. I thought "sed '/^&/d' < temp.text > new.text"
should do it, but it didn't touch a thing. Anyone else know that one?
JSR/
On Fri, 2005-09-09 at 19:00 +0300, Jukka wrote:
> Hi!
>
> I may have asked this already some time ago, but could someone tell me
> an easy way to remove blank lines from html-document? A regular
> expression to be used with text editors "replace"-function...or maybe
> a shell script?
>
> -Jukka
More information about the Christiansource
mailing list