From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32234 invoked from network); 15 Jul 2021 22:29:59 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 15 Jul 2021 22:29:59 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 466799C84D; Fri, 16 Jul 2021 08:29:57 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 3FB2C9C7F1; Fri, 16 Jul 2021 08:29:45 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=iitbombay-org.20150623.gappssmtp.com header.i=@iitbombay-org.20150623.gappssmtp.com header.b="jfW8cSjW"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 4E73A9C7F1; Fri, 16 Jul 2021 08:29:44 +1000 (AEST) Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by minnie.tuhs.org (Postfix) with ESMTPS id 2773D9C7F0 for ; Fri, 16 Jul 2021 08:29:43 +1000 (AEST) Received: by mail-qk1-f172.google.com with SMTP id s193so6815071qke.4 for ; Thu, 15 Jul 2021 15:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iitbombay-org.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=jGMywUwgkFfoWdG5DwdZTMZTENMyPYGqYA1s4wUmYaI=; b=jfW8cSjWAIy46vEpRT7QPDkzFeOvAaks2GXLjBE2VyotDSzxtxn6LaNy3EzaOF0g+S kjveOmDTrnaUstjAGBUrbcFULtpXlcEiHhEZqc7WIZv3AccN+z2KrMMI60KZi0sK40fe /LNNZdwn8cA7bLlg/xuqFAcLqxpXJm/qu4CsA21pL/3r93SubVxcBZvQ6SLvaYeL+D+S 4BzRoQ77h/0qBxb/8zJBf3vLylP7/qZKElobY68JcTyhT9yRrUFZt17nZ3TgLKWqV+w6 J+pFhQ51OPC472Z1/kcus+WuUiAoGR6sztb9fohrLl/geIfSwwSCQTzm30ULQpoYqRYD IT9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=jGMywUwgkFfoWdG5DwdZTMZTENMyPYGqYA1s4wUmYaI=; b=B7feL57q4SnM7UL+i8VGzTnimKcMHBSw3+5hnOBY2Qgen8atbpCrcU2mpjgKwbI5Kc 88AngTEHJU8Ls/EhFNq01nE04bCcl8B8lt6mBEyrq7YUU2B/36SgFpNvDFuNC9bINRPe /X0P0TmM7m9cJdO/15smPVvlrECqjHfdx00WkG/0u8EwUq8KVGU34p8UXAnbBpgC1319 pXZWPT4mssTZs3n1+6sRga4aF0H8IxF5+mAIBAFl7EdI0QoVVJgiwVa1e5M3tqL5/Ji+ yMHRlI20QBovn5+LaVOs8lLVS3X8wXJVmSrSnAX+Be4d/aNQmWT4IdBZYIkP/nan1G87 u1FA== X-Gm-Message-State: AOAM530qb2FQ4zwYbGsnHwjT4Ati2JnuagxbZuJL0L3Mm6sJK+f4I3OL E6BVfLJT2QTD2EoRwDYGnwpd/sIbCjzRqg== X-Google-Smtp-Source: ABdhPJy6vEsulANhWxOX008gVB5+2Dgh8Z3zbar5TNEXS3OgWbcCd8m8u9neVf/P6nUZ6eLLvBoF2A== X-Received: by 2002:ae9:ed03:: with SMTP id c3mr6255693qkg.418.1626388182094; Thu, 15 Jul 2021 15:29:42 -0700 (PDT) Received: from smtpclient.apple (107-215-223-229.lightspeed.sntcca.sbcglobal.net. [107.215.223.229]) by smtp.gmail.com with ESMTPSA id e12sm2427032qtx.73.2021.07.15.15.29.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jul 2021 15:29:41 -0700 (PDT) From: Bakul Shah Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Date: Thu, 15 Jul 2021 15:29:40 -0700 References: To: TUHS main list In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3654.100.0.2.22) Subject: Re: [TUHS] head/sed/tail (was The Unix shell: a 50-year view) X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" On Jul 14, 2021, at 7:38 PM, Douglas McIlroy = wrote: >=20 > -r is weird because it enables backwards reading, but only as > limited by count. Better would be a program, say revfile, that simply > reads backwards by lines. Then tail p has an elegant implementation: > revfile p | head | revfile tail -n can be smarter in that it can simply read the last K bytes and see if there are n lines. If not, it can read back further. revfile would have to read the whole file, which could be a lot more than n lines! tail -n < /dev/tty may never terminate but it will use a small finite amount of memory. -- Bakul