Re: cut off last lines of a document

From: Archimedes Gaviola <archimedes.gaviola_at_gmail.com>
Date: Fri, 01 Sep 2023 09:50:06 UTC
Hi Ede,

Please try.

head --lines=`wc -l <file> | awk '{print $1-3}'` <file>

Thanks,
Archimedes

On Fri, Sep 1, 2023 at 5:37 PM Ede Wolf <listac@nebelschwaden.de> wrote:

> Am 01.09.23 um 10:43 schrieb Ede Wolf:
> > Hello,
> >
> >  From a file/output with an unknown amount of lines, I would like to
> > filter out, or not display, the last 3 lines. Is there a way to archive
> > this?
> >
> > For those also using linux, there is a "head -n -3" for this. That
> > negative number option is not available on FreeBSD, but maybe there is
> > an alterative way of doing this? Preferably /bin/sh compatible.
> >
> > Thanks
> >
> > Ede
> >
>
> As a sidenote: If possible, I would like to avoid using "tail -r | tail
> -n +4 | tail -r" as well, as it again is specific to FreeBSD, so if
> there is a more universal solution, that would be preferred. Even though
> this of course is a FreeBSD mailing list.
>
>
>