Re: to remove leading and trailing blank lines

Davide Brini <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On Mon, 01 Jul 2013 10:24:43 -0000, "contact2vikas"
<[email protected]> wrote:

> Hello,
> I want to remove/delete  leading and trailing blank lines from a file.

Try this:

sed '

/./,$b ok

d

:ok
   
/^\n*$/{
  $d
  N
  b ok
}

' file



-- 
D.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.