From nobody Fri Sep 01 09:50:06 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 4RcYDW2CRxz4sJng for ; Fri, 1 Sep 2023 09:50:19 +0000 (UTC) (envelope-from archimedes.gaviola@gmail.com) Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (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 4RcYDV5Dqbz3Xp1 for ; Fri, 1 Sep 2023 09:50:18 +0000 (UTC) (envelope-from archimedes.gaviola@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-99bcf2de59cso214010766b.0 for ; Fri, 01 Sep 2023 02:50:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693561815; x=1694166615; 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=LUrboPDkFwx86tu6qHtOmbsLpYsg1thO+8+h2kTjhjY=; b=PAYUT2Nes1Q7GD2HW116BP8cOYjsAUfCtPER43mwUkLFhPgIBLKoEVhfUiLcDZX54M ssZEQ4lfxj+pM+fzSequ+rC7wmy2UkIN6S9fjeWo5FXgJFssswktMx7554HCYSS+9/Ts wezUDrsL/ZF368LKFm6M/34H1BuJsSYep4bIMSZ41mZsKtChRU/++PWm4oCXEZ72e2/u AgrtUEmwBChv0PN0QzmqCkG26BCBxveDUcmtLKFFBCwlaugX7p+7SGNO4Ra3YsEDihv1 +11/58sQr6o1+2Gl6kcC82otDYOC4rHL5RwTr0eyJo584afxfZc9FJHy7ylVpoFkNeCh hA9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693561815; x=1694166615; 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=LUrboPDkFwx86tu6qHtOmbsLpYsg1thO+8+h2kTjhjY=; b=g8cO4jfk25CtETGuLk9WVIP5ZRz9zPYaT1Tf9kVrTwUg1r/D9vILtPEWQY+0AgVg/0 wRg+yYZsEXTqxJhvmwyXeg38ZpB/3iUhVZZItstZg560XglienC4fv1XrH4//RjCptd9 Z+8DufbxsJa0sGBzVPK4DBWymVG6hcac4Jv/te9P8YT1uCjC2zRMIsBBsxoAq/1dsXNG U2HOmAQ5Xl4FIRSRJ+WDMqK/NV87wT5hK/7YeGYyR9yQUMyVSMcV/IJ8HcxJ4SETs4sD YnVVy+KR2XG8hyYnMjwx6sNNiSPuaVEaQN/9aQgot7bD00W4dexG8cHcpkiL3n321q5j xFJw== X-Gm-Message-State: AOJu0YwOpgR4WvgRMPNHOoOX6I4OaF04sMJhzWDZ6NmWj5ZnuM/jOQ+1 ecaC8pI1Pb2W6Nsr4HukO3+oyn3RPZsxJH0FClzobHANjoI= X-Google-Smtp-Source: AGHT+IE4706KLLHQombMVWPN3clUI9FYvO7/QyxlhbuF/V0kZuolkUpVS8XLb/yRaYIA8zZpnOFOj+sZv8UvGvmVEGg= X-Received: by 2002:a17:907:78c1:b0:9a1:c991:a51c with SMTP id kv1-20020a17090778c100b009a1c991a51cmr1434353ejc.2.1693561815241; Fri, 01 Sep 2023 02:50:15 -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: Archimedes Gaviola Date: Fri, 1 Sep 2023 17:50:06 +0800 Message-ID: Subject: Re: cut off last lines of a document To: listac@nebelschwaden.de Cc: questions@freebsd.org Content-Type: multipart/alternative; boundary="00000000000067154f06044916bf" 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]; TAGGED_FROM(0.00)[] X-Rspamd-Queue-Id: 4RcYDV5Dqbz3Xp1 --00000000000067154f06044916bf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Ede, Please try. head --lines=3D`wc -l | awk '{print $1-3}'` Thanks, Archimedes On Fri, Sep 1, 2023 at 5:37=E2=80=AFPM 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. > > > --00000000000067154f06044916bf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Ede,

Please try.

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

Thanks,
Archimedes

On Fri, Sep 1, 2023 at 5:37=E2=80=AFPM Ede Wolf <listac@nebelschwaden.de> wrote:
Am 01.09.23 um 10:43 sch= rieb 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.


--00000000000067154f06044916bf--