sed question...
Gary Kline
kline at tao.thought.org
Tue Sep 25 10:16:27 PDT 2007
On Tue, Sep 25, 2007 at 01:05:06PM -0400, Howard Goldstein wrote:
>
>
> Giorgos Keramidas wrote:
> > On 2007-09-24 20:52, Gary Kline <kline at tao.thought.org> wrote:
> >
> >> On Mon, Sep 24, 2007 at 11:07:20PM -0400, Howard Goldstein wrote:
> >>
> >>>> # delete the last 10 lines of a file
> >>>> sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1
> >>>> sed -n -e :a -e '1,10!{P;N;D;};N;ba' # method 2
> >>>>
> >>>> Question two, can sed do its thing inline?
> >>>>
> >>> Wouldn't it be easier to use head -n 18 ?
> >>>
> >
> > If you _know_ that the file has 28 lines, yes. If you don't,
> > then itmay be tricky to 'guess' that -n 18 is the right option.
> >
> >
> In the bits you snipped he said he wanted to ditch everything after the
> 18th line.
Not 'xactly. Given a file of, say 200 line, I want to exact
just the middle. Roughly everythiing after #155, and from the
end, -19 to the EOF.
>
> I didn't realize complexity was the goal. Is this a homework assignment
> Gary?
Errm, only working toward one, Howard.
--
Gary Kline kline at thought.org www.thought.org Public Service Unix
http://jottings.thought.org http://transfinite.thought.org
More information about the freebsd-questions
mailing list