From nobody Mon Sep 4 14:39:25 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 4RfWVm44Hvz4rtPW for ; Mon, 4 Sep 2023 14:39:28 +0000 (UTC) (envelope-from des@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RfWVm3f7fz3Csh; Mon, 4 Sep 2023 14:39:28 +0000 (UTC) (envelope-from des@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693838368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8l/KuBav7NLVAvkvXD9NKU6gJCU0IlxTZtY2+KL9NJs=; b=uDi6hMO32HRNQE7r8CF4/bftJDZVpSXIfDCjoVU0RqkDALk/GOK+lNX0OfCSL0R1jXi4gL ammdMIBpQhIBMJRqPLr17aisGoOPn8XPaFRZy7OTFn/fxA45X3TAOrGQNe+CU64mfzLrHp VkyK5GX3p2U9EED7m0Fo2LwmZSTAQ+3cQL9mn5DhHLZL63Shrv/0oe4DuFYPAuE4WDs1u7 EiSGZestyPbeRgjITLCA7vdk06qXwuRblGiHqzy4ar8LySr7Z6JrnCzZl3kXxWYCy+aRHp 8sz1Bweprl3GhKKL8kLCtD4ayVFdKgycb9SLVKrJvVBZhmdTXxxIyKksUSbGVg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693838368; a=rsa-sha256; cv=none; b=D6qoQsxIdMLXssmLdlOmINmwp3ALpACarqwEgpzzWDM5+Urk612VDB/R9D/8wn/tByTEer y2SCCst+nFROQKlad0RVtO+NUMzTfrvmjZ5K884XxQlbZm9Aq6fTVnpK1sVHvUMH3YSFk7 kQPDgi1mwIeHdCbaPIrk7rTo/cvMCFUpsp+36eHTl7z+LUmFeLdOspxpRpH1OWlMGEjgVO MLTU+s4jtxDfIp/K772B+sdIHDQ35U8n4Co6qRKSSbW3bWOGSqFePhbhRtyEWG5woLjaKz wtLshZAGd1ohU7Pfz7H39nFOLmRikpvZzZPCaoweduFV4aOqlWF+g7LvMe7L1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693838368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8l/KuBav7NLVAvkvXD9NKU6gJCU0IlxTZtY2+KL9NJs=; b=bZPRBSSW5a/8JHqY22WnC2TrEWHPybys1KgCfzwdxh5iy1I9+sBqUyV+Ka9kCcwOlY1J+S 8GgQAeT8FOByZKlbUqOQHgzzW8ay+OVvmyuWckHLR+QUu8tS2ZPKwkRShOW/uxmyuP50j9 5MA2vp+BhNv5DVqCQT63x8HtTCZL6dqz26q0dKyGN61vOUajSG0Ud9OsKay4Sa7ODoh6r1 NPrSkRbBb/PmRN9XhFEAbnYZ34MltcLRz11U+L8Wx9AwiswuN+yqoOhabTPPgbh5dD4IKM dLjiPeTHP0esWuqKjd8Y+QCKfeom5nn8mAKk55Ztt3yALow98WmE7awBx5251Q== Received: from ltc.des.no (ti0187a400-1976.bb.online.no [85.166.95.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: des) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RfWVm1v1wzqpB; Mon, 4 Sep 2023 14:39:28 +0000 (UTC) (envelope-from des@freebsd.org) Received: by ltc.des.no (Postfix, from userid 1001) id D14244E2B5; Mon, 4 Sep 2023 16:39:25 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Ede Wolf Cc: questions@freebsd.org Subject: Re: cut off last lines of a document In-Reply-To: (Ede Wolf's message of "Mon, 4 Sep 2023 08:53:58 +0200") References: <57be5495-97f8-4f22-9ae2-cd9712596e64@nebelschwaden.de> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Mon, 04 Sep 2023 16:39:25 +0200 Message-ID: <86edjet336.fsf@ltc.des.no> 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ede Wolf writes: > Am 03.09.23 um 23:16 schrieb paul beard: > > export COUNT=3D`wc -l /var/log/messages | tr -d -c '\n[:digit:]'` # > > export WANT=3D`echo "$COUNT-3" | bc ` # subtract 3 (or however many) > > head -$WANT /var/log/messages # display the remainder. 1) there is no need to export the variables 2) don't use backticks, use $() instead 3) if you use 'wc -l Thanks, but the problem I currently see here, as with the suggestion > of Archimedes earlier, I am currently not easily able to convert this > into a feed from stdin. Pipe-friendly pure shell solution: drop_last_three() { local a b c d read a read b read c while read d ; do echo "$a" a=3D"$b" b=3D"$c" c=3D"$d" done } DES --=20 Dag-Erling Sm=C3=B8rgrav - des@FreeBSD.org