Re: to remove leading and trailing blank lines

prem <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
The requirement is as follows:
=====================================================================
Hello,
I want to remove/delete leading and trailing blank lines from a file.
Vikas
====================================================================="leading and trailing blank lines" not blank lines.
If that is what you want, this shoud resolve:
echo -e "  ccc\n  dddd  \neeeee  \nfff\n \n\n\n\n" | sed -e '/^ /d' -e '/ $/d' -e '/^ *$/d'
 

From: Alexander Krasnukhin <[email protected]>
>To: [email protected] 
>Cc: [email protected]; prem <[email protected]> 
>Sent: Monday, July 1, 2013 12:36 PM
>Subject: Re: to remove leading and trailing blank lines
>
>
>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]
>
>
>
>------------------------------------
>
>-- 
>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.