Unix Shell - Trim file with sed

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > October 2005 > Trim file with sed





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Trim file with sed
km_jr_usenet@yahoo.com

2005-10-28, 8:48 pm

Hi all,

I have a file format where two parts are delimited by a newline (\n)
character. I need to get the file after the \n character. I tried this
but it gets me the \n character too in o/p.

E.g. if file is
a
b
c

d
e

then I want
d
e
as o/p.

I tried this sed expression -- sed -n '/^$/,$p' <file> but it doesn't
do the desired effect. Can anyone help me here?

Thanks.

Jan Schampera

2005-10-29, 2:49 am

km_jr_usenet wrote:

> E.g. if file is
> a
> b
> c
>
> d
> e
>
> then I want
> d
> e
> as o/p.

What about 1,/^$/d (untested, also unsire if all sed's accept this
addressing mixture).

J.

--
"Be liberal in what you accept, and conservative in what you send."
- J. B. Postel, master of the net.

William James

2005-10-29, 2:49 am


km_jr_usenet@yahoo.com wrote:
> Hi all,
>
> I have a file format where two parts are delimited by a newline (\n)
> character. I need to get the file after the \n character. I tried this
> but it gets me the \n character too in o/p.
>
> E.g. if file is
> a
> b
> c
>
> d
> e
>
> then I want
> d
> e
> as o/p.
>
> I tried this sed expression -- sed -n '/^$/,$p' <file> but it doesn't
> do the desired effect. Can anyone help me here?
>
> Thanks.


awk 'BEGIN{RS=""}2==NR' infile

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com