[plug] A question about using sed - removing blank lines

Nick Bannon nick at ucc.gu.uwa.edu.au
Fri Apr 25 17:08:08 WST 2008


On Fri, Apr 25, 2008 at 03:29:00PM +0800, Arie Hol wrote:
> I have tried using the following command to remove the blank lines :
> 
> 	sed -ie "s/^\s*$//i" *.html
[...]

First - sed doesn't understand all of the extended Perl-style regular
expressions. Use [	] instead of \s , where the brackets contain a
space and a true tab character, ASCII 32 and ASCII 9. You can type the
tab character into a shell or vi with <CTRL-V><CTRL-I>.

Second - that will remove the space characters, but not the actual line,
you'll be left with blank lines that /^$/ would match. Try this: 

	sed -ni.bak '/[^ 	]/p' *.html

Nick.

-- 
   Nick Bannon   | "I made this letter longer than usual because
nick-sig at rcpt.to | I lack the time to make it shorter." - Pascal




More information about the plug mailing list