From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 06 10:29:51 2020 Received: (at submit) by debbugs.gnu.org; 6 Mar 2020 15:29:51 +0000 Received: from localhost ([127.0.0.1]:45712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAEv8-0005p9-I8 for submit@debbugs.gnu.org; Fri, 06 Mar 2020 10:29:50 -0500 Received: from lists.gnu.org ([209.51.188.17]:37730) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jA9V1-00061E-Om for submit@debbugs.gnu.org; Fri, 06 Mar 2020 04:42:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55564) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jA9V0-0006r8-Im for bug-coreutils@gnu.org; Fri, 06 Mar 2020 04:42:31 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jA9Uz-0004bh-9R for bug-coreutils@gnu.org; Fri, 06 Mar 2020 04:42:30 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:34451) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jA9Uz-0004Yj-0E for bug-coreutils@gnu.org; Fri, 06 Mar 2020 04:42:29 -0500 Received: by mail-wr1-x42b.google.com with SMTP id z15so1548477wrl.1 for ; Fri, 06 Mar 2020 01:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=wuQZtR3iYDGi7DN99bsGrtl2CiYr7vC2g5Cobl993qo=; b=Y4i2q9uZhkRcQDyTSqNrsj8HKkowgMwpQIyt+4s5iPyQsos9dxLuWjMykedBvx+puf Z+L5oRgIaMFO61acig1feQLc3dL1pfkCj5ZQMz36jqFrGnanWLsUTu83bsl7vbzkIxHF I5bx79cVBHtCebWwnQ/8Nt7blUdQ2/e4phqjTIaQVQS7GL94fFc6XJhr7WPWTITIocDT OhjLCHr0nmeseXwANvX7HyUduyXCJMQ2CuNx+hGaopUAi7Aq/k6/CWDQYrJvR9UNIgjR BeSIB5kGo+5mK1JzY3Wi5hamD4IgI2oOY0d5okRjk37G2WePMD7UNxmpq1K58WlMvQeK 6DZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=wuQZtR3iYDGi7DN99bsGrtl2CiYr7vC2g5Cobl993qo=; b=Arzsdlt+IqqL5Vk0Zrw7fCivZKgcfEJTzCxB7nk/qcXTbixLBGJEbzyKKgQd9WNhHQ oW4Fv4WHkFeblYCc29XigMfNcj0R5GzTk9MMVUoDgtpe1wwpkR7S3nRUgylDD98mnZFu o1XJcISs0HcTX15e96iIov7pSpEIpSIM8hPdQuG3pLqTwchd4elvJCEK+CDv9kUmTfKD AYrJzJq2EkitSX6CIipPavn3+Dkym5TbFA4Cx3Vp+4uInzPTtl9TsksI0sV4/I3LI1w9 1d23X3NRlwHLclNIPKe7paOqvOXLxuNtIJKo1mh5wq1DG+RAZEeITYUymucb2ofJp4Ky gWjg== X-Gm-Message-State: ANhLgQ3usZKiQdyLZGAMZamiTiYoN7gTZb99bwymc/Wg+MbgpkHTFg1k LDQe6BHeRKpW0i1ANh99H0icRJxEu7te31aV0tyNBRql X-Google-Smtp-Source: ADFU+vszCkj5k80Bm7dE9BMBbrkLNvXG7/cHLuCxMOGXzqHOmSaynwmoe4YB3Ri4VyTNCQ0aGz0P/SQUf+XP0LKcN3Q= X-Received: by 2002:adf:a411:: with SMTP id d17mr3130669wra.126.1583487746928; Fri, 06 Mar 2020 01:42:26 -0800 (PST) MIME-Version: 1.0 From: Dimitris Moraitidis Date: Fri, 6 Mar 2020 10:42:15 +0100 Message-ID: Subject: tail -n +NUM is not working properly To: bug-coreutils@gnu.org Content-Type: multipart/alternative; boundary="000000000000a9736c05a02c787b" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 06 Mar 2020 10:29:48 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --000000000000a9736c05a02c787b Content-Type: text/plain; charset="UTF-8" Hey there, tail -n + NUM does not return the desired output. +NUM starts from the top of the file, not from the bottom. So for example, given the following file: >this >is >an >example >file >each >word >represents >a >line and executing tail -n +3 example, I am getting >example >file >each >word >represents >a >line instead of >this >is >an >example >file >each >word I am using *tail (GNU coreutils) 8.28 *in latest ubuntu 18.04 LTS Thanks in advance for looking into this :) -- // Moraitidis D. Dimitris, // Athens University of Economics and Business (AUEB) // Department of Informatics --000000000000a9736c05a02c787b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hey there,

tail -n=C2=A0+ NUM does not = return the desired output.=C2=A0+NUM starts from the top of the file, not f= rom the bottom.

So for example, given the followin= g file:

>this
>is
>an
>exampl= e
>file
>each
>word
>represents
>a
>lin= e

and executing tail -n=C2=A0+3 example, I am getting
=
>example
>file
>each
>word
>represents
&g= t;a
>line

instead of=C2=A0


>this=
>is
>an
>example
>file
>each
>word
I am using=C2=A0tail (GNU coreutils) 8.28 in latest= ubuntu 18.04 LTS

Thanks in=C2=A0advance for looking=C2=A0int= o this :)

--
// Moraitidis D. Dimitris,
// Athens University of E= conomics and Business (AUEB)
// Department of Informatics=C2= =A0
--000000000000a9736c05a02c787b-- From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 06 12:32:23 2020 Received: (at 39951) by debbugs.gnu.org; 6 Mar 2020 17:32:23 +0000 Received: from localhost ([127.0.0.1]:45870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAGpj-0004ON-2U for submit@debbugs.gnu.org; Fri, 06 Mar 2020 12:32:23 -0500 Received: from mail-ot1-f54.google.com ([209.85.210.54]:34832) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAGph-0004OA-Gf for 39951@debbugs.gnu.org; Fri, 06 Mar 2020 12:32:21 -0500 Received: by mail-ot1-f54.google.com with SMTP id v10so3214002otp.2 for <39951@debbugs.gnu.org>; Fri, 06 Mar 2020 09:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7xC4PpI/PeZqMcFJZEA9RYDvCtEYx37e3UKquKYwn0I=; b=SuQLF6kDhsJMadLNdwkki886EFBgxtWBw/ASxmlwSf7SYjXR2t6Igx547Pd5tV1Dki zQKA7aHG0/W1d9teZVw/jXW5vE8JT76YFjj0Eboov+idIKC+kvr9V1L+ksKeydIi78Dq KRjN5nbbF+b03sTJ0YcGfVNgGts70sOAwEPfSTNkO37HF2DAqDkgug/YKQD3xQUUTET1 yixP2kCaXC1qG81QQUDWS4mhRWkQn/DyneiNCFnTLovBLVBrBYQZf9so4Lhj3mhU07/w odmV+oYtMsBUbxWP5jFcJqeQbyw2Dt9k/iNx2IRorRYjMKj3I71Mq8CH3ePtf83Gc3Cj /lbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7xC4PpI/PeZqMcFJZEA9RYDvCtEYx37e3UKquKYwn0I=; b=D+qkvWIDMPjOA6f6lpQXz+IVDAqDyYRZn4CItsjpjKMYW1eM1BB0HKM2oXI9n8jxD5 hgs8hIpGAmBAlDdOAJqYgjNzM3nhy41nciBCYq9uEPz4VrwbuVUVCr/4Vb2GSmUOSUVs RO9V03jtqLOaQQ8GpU59nW9RCwNbi60MStCJGvjYDiwBA/nl5XsiyY5LLrjLnWzvgeFH cwizuybRuYv8QfxpwyUi0XfK+xXjr5qMcivsAJr1Qc+bplgdaGFIbzjM7jBvkW9SSVlu TOYuJz8aINzstLDlmZfXpgqK5K01F23O4pvVcYBBZ6El0uu1nexvoZiBWI5lzXysGO9f 3ywA== X-Gm-Message-State: ANhLgQ0iTjuc/SvnvULXk3XSyKRxmjnxi5R1FQ8QamWhigCMNQmiMecG XsOTw/ZEZS2BRIBARh3m+6+lln0TeD+zx+de3DA= X-Google-Smtp-Source: ADFU+vvhpOjfcawpl02flOKbeHVRSFKFTfX0UbV9h3IOksrC/t2vob+ub91sLHUsAllbQYKsGokv0WWR1YGrx10skLQ= X-Received: by 2002:a05:6830:1503:: with SMTP id k3mr3587376otp.28.1583515935801; Fri, 06 Mar 2020 09:32:15 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Michael Speer Date: Fri, 6 Mar 2020 12:32:04 -0500 Message-ID: Subject: Re: bug#39951: tail -n +NUM is not working properly To: Dimitris Moraitidis Content-Type: multipart/alternative; boundary="000000000000d984f905a03308a7" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 39951 Cc: 39951@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000d984f905a03308a7 Content-Type: text/plain; charset="UTF-8" you want the `head` of the file sans the last few lines, rather than the `tail` of the file sans the first few. from the man page for tail > -n, --lines=[+]NUM > output the last NUM lines, instead of the last 10; or use -n +NUM to output starting with line NUM > use -n +NUM to output starting with line NUM so content after the given number of lines from the man page for head > -n, --lines=[-]NUM > print the first NUM lines instead of the first 10; with the leading '-', print all but the last NUM lines of each file > with the leading '-', print all but the last NUM lines of each file this is the one you want. the functionality can seem a little backwards, but makes sense if you consider tail giving data relative to the end and head relative to the start. each then has an option to act relative to the other side of the document. On Fri, Mar 6, 2020 at 10:31 AM Dimitris Moraitidis < dimitris.moraitidis@gmail.com> wrote: > Hey there, > > tail -n + NUM does not return the desired output. +NUM starts from the top > of the file, not from the bottom. > > So for example, given the following file: > > >this > >is > >an > >example > >file > >each > >word > >represents > >a > >line > > and executing tail -n +3 example, I am getting > > >example > >file > >each > >word > >represents > >a > >line > > instead of > > > >this > >is > >an > >example > >file > >each > >word > > I am using *tail (GNU coreutils) 8.28 *in latest ubuntu 18.04 LTS > > Thanks in advance for looking into this :) > > -- > // Moraitidis D. Dimitris, > // Athens University of Economics and Business (AUEB) > // Department of Informatics > --000000000000d984f905a03308a7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

you want the `head` of the file s= ans the last few lines, rather than the `tail` of the file sans the first f= ew.

from the man page for tail

>=C2=A0 =C2=A0 =C2=A0 -n, --lines=3D[+]NUM
>=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 output the last NUM lines, in= stead of the last 10; or use -n +NUM to output starting with line NUM

> use -n +NUM to output starting with line NUM

so content after the given number of lines
=
from the man page for head

>=C2= =A0 =C2=A0 =C2=A0 =C2=A0-n, --lines=3D[-]NUM
>=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 print the first NUM lines instead of the first = 10; with the leading '-', print all but the last NUM lines of each = file

> with the leading '-', print = all but the last NUM lines of each file

this i= s the one you want.

the functionality=C2=A0can see= m a little backwards, but makes sense if you consider tail giving data rela= tive to the end and head relative to the start.
each then has an = option to act relative to the other side of the document.

On Fri, Mar 6, 2020 at 10:31 AM Dimitris Moraitidis <dimitris.moraitidis@gmail.com> = wrote:
Hey there= ,

tail -n + NUM does not return the desired output. +NUM starts from the top<= br> of the file, not from the bottom.

So for example, given the following file:

>this
>is
>an
>example
>file
>each
>word
>represents
>a
>line

and executing tail -n +3 example, I am getting

>example
>file
>each
>word
>represents
>a
>line

instead of


>this
>is
>an
>example
>file
>each
>word

I am using *tail (GNU coreutils) 8.28 *in latest ubuntu 18.04 LTS

Thanks in advance for looking into this :)

--
// Moraitidis D. Dimitris,
// Athens University of Economics and Business (AUEB)
// Department of Informatics
--000000000000d984f905a03308a7-- From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 06 12:35:35 2020 Received: (at 39951) by debbugs.gnu.org; 6 Mar 2020 17:35:35 +0000 Received: from localhost ([127.0.0.1]:45877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAGso-0004Te-Vz for submit@debbugs.gnu.org; Fri, 06 Mar 2020 12:35:35 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:36523) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jAGsn-0004TL-8Q for 39951@debbugs.gnu.org; Fri, 06 Mar 2020 12:35:33 -0500 Received: from [10.0.2.16] ([62.153.148.194]) by mrelayeu.kundenserver.de (mreue106 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MtfeD-1jUp290wKF-00v6fZ; Fri, 06 Mar 2020 18:35:26 +0100 Subject: Re: bug#39951: tail -n +NUM is not working properly To: Dimitris Moraitidis , 39951@debbugs.gnu.org References: From: Bernhard Voelker Message-ID: <68355466-1bd2-538d-f0f1-fb732b142e0a@bernhard-voelker.de> Date: Fri, 6 Mar 2020 18:35:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:WQROIq6nZcVWVI1lcJKiC7tD1PxzjSe1zMQK3p68CtbeG+oViHp 6PXdzsHDZ+gmne1Pk+QC4fDZ1M5r3VCrsaBX5fhIGYJ0YOLo6OhB1vOuHWZkRqcg14Ts5tC bCm+OCFdg35Udj1UXkVWHHEZkAaGD70o7oOFUCCrs6To929fsNbVlSphkDXx8Ysss1oaiue xdpG0iIIFR9FPGete0RXA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:XSNESRg5wYQ=:GUuMkIPzZgB8Fs0lYa26GM Qv+XaJx1MbeosO8/piFZhuGEsnJRwLbfuFBmdvUUqNzHw5bKDsSS1yzfa9EF6dNuT2Hk4iPLE i41jqNblwe3TlYz6PDYHaO2SXobaPsAe2UYKnGEI6sBzEAW2iT6340ZhU+h4V2hWh3WXg34n4 QR5LmAOLOv6MNVQEfw0tVuPT/rE3+wSN/zJm5bmg6I7gqWzKZDKswxhH7tuaG3Wqzu8DpTM0L DDfgyoExN8mvjKMGUCqxK3CLD/YmVql+PTZJXb2niMKZHKe2FW+ADoN70/uZbdbhyhaX9M8eN R1C1vLcRrWPI+ab6N584oJF42vu5yAkN3FwjRYbhPYF3g7ZjlZ8FDAHjxgvVfP2m1amZb2FGn 22gwZfw/sprcjIby9Fu0b/mbnvi5C28TuhOCEXGKYBIUX3t8o+5VVkwPapAxEg6hTMIUhvyKl 7mfETwxtKOjrr+dLf7kFNtFOoN49aFWdf8KwiW9EIYXfKlzTbDwjS5a6Phc19E68uDgH99wjD iV8Q/aauhyfzvyzcM/CEvtQjasjcfpcbEJaDPPak6oBOGGoXdyJFb92WEOq8aQIAJEsc6d35Q 3aHXSWjAzb7eF4c5PymMuEpFbtZbLeQVrk8HkUBowF3WQcr4dTO/M9WpicoOwJJDj8PyyoYCN rLVzJ4K1uwioMElYQRBiU1LWTXXSbzHeYHcErb41HGv7JjHXA7EdLjtB67fW4hYq2nzUvNjFC dkCbVh8UZJy5uRWRdOFbirLlHzmiiMtcTt76LBVML3tUOKYYNqnPjjsw2//Psd0sj/rKSRUs/ 1O5j7HNsr6FFVWTrM3a50pEue7pThe4gIwnE31lj+xg9QJ7ypN6QrFzBZMTL8VzEmKasYIc X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 39951 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.5 (--) On 3/6/20 10:42 AM, Dimitris Moraitidis wrote: > Hey there, > > tail -n + NUM does not return the desired output. +NUM starts from the top > of the file, not from the bottom. > > So for example, given the following file: > >> this >> is >> an >> example >> file >> each >> word >> represents >> a >> line > > and executing tail -n +3 example, I am getting > >> example >> file >> each >> word >> represents >> a >> line > > instead of > > >> this >> is >> an >> example >> file >> each >> word > > I am using *tail (GNU coreutils) 8.28 *in latest ubuntu 18.04 LTS > > Thanks in advance for looking into this :) Isn't this exactly what tail(1) is support to do when the user explicitly passes the '+' sign to the number? $ tail --help | grep -A1 -- --lines -n, --lines=[+]NUM output the last NUM lines, instead of the last 10; or use -n +NUM to output starting with line NUM Also POSIX says so: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/tail.html Have a nice day, Berny