|
Home > Archive > Unix Programming > 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
|
|
| Kelvin Moss 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.
| |
|
|
Kelvin Moss 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.
You could do it with grep.
Something like
cat FILE | grep "" -x -A 10000
(or bigger number for -A if the file is really big!)
| |
| Chris F.A. Johnson 2005-10-29, 5:51 pm |
| On 2005-10-29, Kelvin Moss 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?
sed '1,/^$/d' FILE
--
Chris F.A. Johnson | Author:
<http://cfaj.freeshell.org> | Shell Scripting Recipes:
Any code in this post is released | A Problem-Solution Approach,
under the GNU General Public Licence | 2005, Apress
|
|
|
|
|