From nobody Fri Sep 08 00:02:13 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 4Rhbrz1nT0z4swMv for ; Fri, 8 Sep 2023 00:02:27 +0000 (UTC) (envelope-from tom.browder@gmail.com) Received: from mail-ua1-x934.google.com (mail-ua1-x934.google.com [IPv6:2607:f8b0:4864:20::934]) (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 4Rhbry16PJz4dlS for ; Fri, 8 Sep 2023 00:02:26 +0000 (UTC) (envelope-from tom.browder@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20221208 header.b=AkZY9h9L; spf=pass (mx1.freebsd.org: domain of tom.browder@gmail.com designates 2607:f8b0:4864:20::934 as permitted sender) smtp.mailfrom=tom.browder@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ua1-x934.google.com with SMTP id a1e0cc1a2514c-7a2ab581cb1so620502241.1 for ; Thu, 07 Sep 2023 17:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694131345; x=1694736145; 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=ZsP7N4nb8eIqKCNwGbdVp2qYdu8HJH0/MhRibQz2z/U=; b=AkZY9h9LBNzNIldsCiMuR64EeSk+zQa/dMfxwd7G6arDiTgrQv9JXTJcK/v+V0XsiR gR/040BTP54VnDLuLAd5z4IawEzOtdutClckJN03ie4TaEF6xI9wck/YH6WVwAJ45ATU +atITyyFo6Lx2mhSFcEiy0V4iANaKys7KLA9uZyMlmwXL08QoTkRrBJFnRsNxY83HtMw Eq+Cr7S5v/t2lL2meQp1p/FFh9Tyi9DMu4GbdrTUiuyjDcTTna6aug60DMnljfcmxzOX Jk5GXW55m9OpO0inUczBnxMfA0pZ0FQuWY4zJoRvDhTVutIg++LFLPFegNRLnwreuikS U2vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694131345; x=1694736145; 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=ZsP7N4nb8eIqKCNwGbdVp2qYdu8HJH0/MhRibQz2z/U=; b=QilNHsrrVxDUglavSYjt10rQcHwpvq/GxzSwLkpEiVaa0di/k/wDM06X9AQoqJE18i 1SIvXmFT254YI7+vtTVtkQgS4euhPXaTbxNNkWGE88CgOA6tJJXzKTICb4jeVYNMNgaj kqX3LcoIQKOnqX5hGNAA+juiF8SyySlyGo69M05lo+kaa540Bb+/KDFOKbBj1cVFX2ft xAafapD4oBPoH0Cip1gHmiX/iB3D09VMO6EGYZSOHcc91T78I7v/kbgzwxNAmu/8SV+X XksHEIFTwfK4R6m5CTwQoUTA9ZHidxfZkWvtDODvOAwriKwFajggxBX4Vs2DOZZ+dg4y Essw== X-Gm-Message-State: AOJu0Yyhvswtn2JGX2IDhSWgLGWtxHfjlk2E4QKf8NardJEdiXMV6vN6 gSupTXxuL4l7ak3OWUTv5CG+eIxOOJ4/8e5YB/riXn+k X-Google-Smtp-Source: AGHT+IETc/NpOrnhWVdcDY+eYGkBDv7svr/69A+7N+OemBFyoMyD21ZROHTfWfOhfPffTrrfSjP9gk+Xp4RufFsPlgU= X-Received: by 2002:a67:f557:0:b0:44d:5b62:bcd5 with SMTP id z23-20020a67f557000000b0044d5b62bcd5mr1350282vsn.23.1694131344997; Thu, 07 Sep 2023 17:02:24 -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: <57be5495-97f8-4f22-9ae2-cd9712596e64@nebelschwaden.de> From: Tom Browder Date: Thu, 7 Sep 2023 19:02:13 -0500 Message-ID: Subject: Re: cut off last lines of a document To: listac@nebelschwaden.de Cc: User Questions Content-Type: multipart/alternative; boundary="0000000000000581300604cdb108" X-Spamd-Bar: --- X-Spamd-Result: default: False [-4.00 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.999]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20221208]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[questions@freebsd.org]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TAGGED_FROM(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::934:from]; DKIM_TRACE(0.00)[gmail.com:+]; MID_RHS_MATCH_FROMTLD(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_TLS_LAST(0.00)[]; MLMMJ_DEST(0.00)[questions@freebsd.org] X-Rspamd-Queue-Id: 4Rhbry16PJz4dlS --0000000000000581300604cdb108 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Sep 1, 2023 at 05:23 Ede Wolf wrote: > 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? Ede, I would like to know your use case. You have had lots of suggestions of arcane shell scripting solutions for use on any Unix-like host, but I want to suggest an alternative which is even more universal: use a Raku script (see the solution below). Let me explain. Short version =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D In any line of work, I believe you should automate any work you can to give more time for other tasks. For the work that can be automated by shell scripting, Raku provides easier coding and easier maintenance. Long version =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D In my younger days I was a semipro sysadmin for years with a DoD contractor. I introduced Linux for our CAD developers when we were still using SGI workstations that cost about $25K and $6K annually to support. I introduced the old Yggdrasil Linux installed on a small IBM PC as a much cheaper alternative as we started weaning ourselves off big iron and providing all analysts with his or her own workstation. Over the years I used Perl to do more complicated sysadmin support for my team of analysts and moved away csh to bash in the process. Note Perl is now available by default on the Linux distros I=E2=80=99m familiar with , but I have been us= ing Raku as its replacement since 2015 and, while not automatically available, it is easily installable as packaged in major Linux distros as well as for NetBSD. Other installation support is provided for Windows and MacOS. See < rakudo.org> for details. RAKU SOLUTION So, with Raku installed, I view a file =E2=80=9Csomefile=E2=80=9D in a term= inal with a Raku one-liner like this at the shell prompt: $ raku -e 'say $_ for "somefile".IO.lines[^(*-3)]' ...all but the last three lines scroll by... (Note I would make the one-liner reusable by putting that line in a bash script file with a suitable and meaningful name, something like "cat-less-3-lines.sh." Happy rakuing! -Tom --0000000000000581300604cdb108 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Sep 1, 2023 at 05:23 Ede Wolf &l= t;listac@nebel= schwaden.de> wrote:
> 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?

E= de, I would like to know your use case. You have had lots of suggestions of= arcane shell scripting solutions for use on any Unix-like host, but I want= to suggest an alternative which is even more universal: use a Raku script = (see the solution below). Let me explain.

Short version
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

In any line of work, I beli= eve you should automate any work you can to give more time for other tasks.= =C2=A0 For the work that can be automated by shell scripting, Raku provides= easier coding and easier maintenance.

Long version
=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D

In my younger days I was a semipro sysadmin for years with a DoD contractor= . I introduced Linux for our CAD developers when we were still using SGI wo= rkstations that cost about $25K and $6K annually to support.

I introduced the old Yggdrasil Linux installed on a small IBM PC as a much = cheaper alternative as we started weaning ourselves off big iron and provid= ing all analysts with his or her own workstation. Over the years I used Per= l to do more complicated sysadmin support for my team of analysts and moved= away csh to bash in the process. Note Perl is now available by default on = the Linux distros I=E2=80=99m familiar with , but I have been using Raku as= its replacement since 2015 and, while not automatically available, it is e= asily installable as packaged in major Linux distros as well as for NetBSD.= Other installation support is provided for Windows and MacOS. See <rakudo.org> for details.
<= div dir=3D"auto">...all but the last three lines scroll by...

(Note I would make the one-liner reusable by putting that line in a bas= h script file with a suitable and meaningful name, something like "cat= -less-3-lines.sh."
--0000000000000581300604cdb108--