Re: to remove leading and trailing blank lines
prem <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <[email protected]> |
Please read the requirement. "I want to remove/delete leading and trailing blank lines from a file." The LINES need to be removed, not the space. In your example, it does not have any leading or trailing space. Also, see my resent email, that deletes blank lines also as requested later. 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]