From nobody Fri Sep 01 15:46:58 2023 X-Original-To: questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rcj8M53NXz4rYvY for ; Fri, 1 Sep 2023 15:47:15 +0000 (UTC) (envelope-from pprocacci@gmail.com) Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rcj8M208kz3Hwk for ; Fri, 1 Sep 2023 15:47:15 +0000 (UTC) (envelope-from pprocacci@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-52c4d3ff424so1559523a12.0 for ; Fri, 01 Sep 2023 08:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693583232; x=1694188032; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=N5XXfG/NZSSRnfFPAok/7dabrE+EVOMcebE7/2RDvMU=; b=NsChOTUdMfrPx+DZ8PDwXytncLUzrjbatpM1DzDtkQNqPwYC8oigKMbeTsUR8RS+ay PARssR9msnudjkU5kZoM2f7IAVVYOcZjTYWbNdrheNgjIAvKIHExdBiaSKdFEyNRMFpQ cytPK97g1fNSrw8Ev3aYgw16dOsX+W/oJiijzav/RqKYdKeOCzz83ODarpjwUXjbNWez yRuu/x5Y4Ej81RxgPc6xUm1yY9Rm3pObpB1M7FfzlVu/PKz7unyuSg1hsubriK70l7b9 +ve68x5njTtmsXLx5eSiIW4E5OR0iwU0s3XjTsKxYkhHICzbWCVxYIdtTcwI0fSxFvNQ ZrPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693583232; x=1694188032; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=N5XXfG/NZSSRnfFPAok/7dabrE+EVOMcebE7/2RDvMU=; b=EaO/0Z+2+7ZyUKwhrRrYrzKTyHiNuavfxo3GppqGwBfVVMona4dwGV8wlxXLbWrxqe ychIQXa7gZU6Ltbcw48kAv7rcRP27HasPofCO+EWSVJEjqy5VCDn8MrdOkWmQtz70qGf V8B6PdCEygmf4m8a2ldFsU2zBriFYKIIjL0my6LlwbDRokRYyDl70FWQ/K4gmXcL/rg8 Ts3730vhZFkWLh3p95aD/cI2Xww1/S/0OQVD3OERBtjQ58/GWFGBU00lhlVJkaYPhZoQ Pmw0HHqX2JOXDo/E1XJ8rCF2L01R7N2RTwvl6QsL+x+gqx06v/5BwpjVBizYJ0SeGDdW 4kYg== X-Gm-Message-State: AOJu0YzzexAsCQqKUoAsRu+LJNXttIWW1jCOX8ZKrAtW/Xcu//T7dwg6 Ydbordi3lN1mbOpQuAyEXFqAH+cUZ1cVHOujPicpiXmuRA== X-Google-Smtp-Source: AGHT+IHs4LXJazX+agizfxHlGVBXRet5zdRBHBZOriVvGGUW3g0v2iqx0h88Q4BcmWu4c+86pcYYCMdXSca36ZNbrBo= X-Received: by 2002:a50:ef1a:0:b0:523:6c47:56f8 with SMTP id m26-20020a50ef1a000000b005236c4756f8mr2720982eds.18.1693583231481; Fri, 01 Sep 2023 08:47:11 -0700 (PDT) List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 References: <57be5495-97f8-4f22-9ae2-cd9712596e64@nebelschwaden.de> In-Reply-To: From: Paul Procacci Date: Fri, 1 Sep 2023 11:46:58 -0400 Message-ID: Subject: Re: cut off last lines of a document To: listac@nebelschwaden.de Cc: questions@freebsd.org Content-Type: multipart/alternative; boundary="000000000000e8fc9606044e1294" X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4Rcj8M208kz3Hwk --000000000000e8fc9606044e1294 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Sep 1, 2023 at 6:53=E2=80=AFAM Ede Wolf w= rote: > 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. > > > With these restrictions, you could use something like: sed -e :a -e '$d;N;2,3ba' -e 'P;D' ~Paul --=20 __________________ :(){ :|:& };: --000000000000e8fc9606044e1294 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Sep 1, 2023 at 6:53=E2=80=AFA= M Ede Wolf <listac@nebelschwa= den.de> wrote:
Am 01.09.23 um 10:43 schrieb Ede Wolf:
> Hello,
>
>=C2=A0 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 archiv= e
> 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 | tai= l
-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.



With these restrictions, you could use something like:

sed -e :a -e = '$d;N;2,3ba' -e 'P;D' <filename>

~Paul
--
_______________= ___

:(){ :|:& };:
--000000000000e8fc9606044e1294--