Re: to remove leading and trailing blank lines

Alexander Krasnukhin <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
It won't remove leading and trailing blank lines.

$ echo -e "\n\n\ncafebabe\n\n\n" | sed -e '/^ /d' -e '/ $/d'

--
Regards,
Alexander

On Jul 1, 2013, at 7:29 PM, prem wrote:

> Try thisecho -e " cccc\n dddddd \neeeeeee \nfffff" | sed -e '/^ /d' -e '/ $/d'
>  
> 
> From: Davide Brini <[email protected]>
>> To: [email protected] 
>> Sent: Monday, July 1, 2013 5:38 AM
>> Subject: Re: to remove leading and trailing blank lines
>> 
>> 
>> 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.
>> 
>> 
>> ------------------------------------
>> 
>> -- 
>> Yahoo! Groups Links
>> 
>> 
>> 
>> 
>> 
>>  
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
> ------------------------------------
> 
> -- 
> Yahoo! Groups Links
> 
> 
> 



[Non-text portions of this message have been removed]
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.