From unknown Thu Sep 11 11:56:31 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#23190 <23190@debbugs.gnu.org> To: bug#23190 <23190@debbugs.gnu.org> Subject: Status: wc - Different output Reply-To: bug#23190 <23190@debbugs.gnu.org> Date: Thu, 11 Sep 2025 18:56:31 +0000 retitle 23190 wc - Different output reassign 23190 coreutils submitter 23190 Seva Adari severity 23190 normal tag 23190 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 02 15:25:45 2016 Received: (at submit) by debbugs.gnu.org; 2 Apr 2016 19:25:45 +0000 Received: from localhost ([127.0.0.1]:49117 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1amRB3-0007Th-GH for submit@debbugs.gnu.org; Sat, 02 Apr 2016 15:25:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40901) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1am78r-0005Pe-Kh for submit@debbugs.gnu.org; Fri, 01 Apr 2016 18:02:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1am78l-0002jI-SH for submit@debbugs.gnu.org; Fri, 01 Apr 2016 18:02:04 -0400 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,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:37468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1am78l-0002jD-Or for submit@debbugs.gnu.org; Fri, 01 Apr 2016 18:02:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1am78k-0005z5-UL for bug-coreutils@gnu.org; Fri, 01 Apr 2016 18:02:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1am78k-0002ix-4X for bug-coreutils@gnu.org; Fri, 01 Apr 2016 18:02:02 -0400 Received: from mail-ig0-x233.google.com ([2607:f8b0:4001:c05::233]:38830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1am78j-0002ip-Uc for bug-coreutils@gnu.org; Fri, 01 Apr 2016 18:02:02 -0400 Received: by mail-ig0-x233.google.com with SMTP id ui10so4429977igc.1 for ; Fri, 01 Apr 2016 15:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=Yr6txuJZXg10+Lc7gzRYz/l1ll53sQJE4q7tHPq9k40=; b=DgI0xPHmAyHJcf4uOG20J4ZPObHcFcUjHAD9HpJFCnRClgslotibAWBsVnNOQn3jyu 3e4tTTfJZXRIEkoNfnrf0hHMMIlUMkGdLkHJDrU8yV5i++xoCCSHaKOUghnMJl42sQeU RRVtbt9+9zT6oJi0fEQiyMOSjkoYVD5/VDOYZ7yVTUWWAhCZywC0IysqP+0pIW1SuM4A T/kMz8ZXFWwL/FSPEjEFmt/QPd6itJsEa1xXZHYm3sX7UA1ETQZeVFX/c9VAsC2V3uar MDh6YDrNRkD7xAWFyv9TbESkr35P+0qACj1cF6R2gkY12igCuvga84/D5IQCivs28dG9 F9Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=Yr6txuJZXg10+Lc7gzRYz/l1ll53sQJE4q7tHPq9k40=; b=D+s6kblGqpj8eDkfd8l3c1zhzHoHCd6I1wQHuNzI8kpf0rav0q4PKTp273zCqCLdsL 8q8JdgC8c0guNWXMyFYlIhgMhwUYS9wMudvy/j+O4s7gNReF/AnIsNa2XRIapBTOPRzQ v5B+QLVDPCOYEpVNFn9KWfLMoHgFL+CCePQwsDoM07AfdzPhInidDAkijgxS4M4WQ+cq 2JaeUtyD0gA5FnE5qRtd7Y06++ctV0IuE/cr1CeTg53Bg+eS96WRmuMA+H8nhRsDC4mR 0roNLbwoTmdusOc9AxD0PsPc4KaPuIybrOk1ceKSRaGzDh1j/orQ3SRVy/a2TFP/daww FAzg== X-Gm-Message-State: AD7BkJKBCvOJhXzXVmwlV/h52K5Fq2iD4TKSAoFvoq4dpHYqbA5dkmBaE8uw+vPlN35ML4riIUhLzc21D73LWg== MIME-Version: 1.0 X-Received: by 10.50.13.35 with SMTP id e3mr1058872igc.71.1459548121032; Fri, 01 Apr 2016 15:02:01 -0700 (PDT) Received: by 10.107.139.209 with HTTP; Fri, 1 Apr 2016 15:02:00 -0700 (PDT) Date: Fri, 1 Apr 2016 18:02:00 -0400 Message-ID: Subject: wc - Different output From: Seva Adari To: bug-coreutils@gnu.org Content-Type: multipart/mixed; boundary=089e011607584a0ca5052f73875f X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 02 Apr 2016 15:25:44 -0400 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: -4.0 (----) --089e011607584a0ca5052f73875f Content-Type: multipart/alternative; boundary=089e011607584a0c9f052f73875d --089e011607584a0c9f052f73875d Content-Type: text/plain; charset=UTF-8 Hello, I am not sure if this a bug or expected behavior! Here is different output from each run variation of wc invocation: wc -l test.txt Output: 20 awk '{print $0}' /tmp/test.txt | wc -l Output: 21 cut /tmp/test.txt -f1 | wc -l Output: 21 Similarly, when I read file from a python program I get 21 line count. File, test.txt (attached here with) could be missing last "new line". Thanks Seva --089e011607584a0c9f052f73875d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: base64 PGRpdiBkaXI9Imx0ciI+PGRpdj5IZWxsbyw8YnI+PGJyPjwvZGl2PjxkaXY+SSBhbSBub3Qgc3Vy ZSBpZiB0aGlzIGEgYnVnIG9yIGV4cGVjdGVkIGJlaGF2aW9yISBIZXJlIGlzIGRpZmZlcmVudCBv dXRwdXQgZnJvbSBlYWNoIHJ1biB2YXJpYXRpb24gb2Ygd2MgaW52b2NhdGlvbjo8YnI+wqDCoMKg IHdjIC1sIHRlc3QudHh0wqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKg wqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqAgT3V0cHV0OiAyMDxicj7CoMKg wqAgYXdrICYjMzk7e3ByaW50ICQwfSYjMzk7IC90bXAvdGVzdC50eHQgfCB3YyAtbMKgwqDCoMKg wqDCoCBPdXRwdXQ6IDIxPGJyPsKgwqDCoCBjdXQgL3RtcC90ZXN0LnR4dCAtZjEgfCB3YyAtbMKg wqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgIE91dHB1dDogMjE8YnI+PGJyPjwv ZGl2PjxkaXY+U2ltaWxhcmx5LCB3aGVuIEkgcmVhZCBmaWxlIGZyb20gYSBweXRob24gcHJvZ3Jh bSBJIGdldCAyMSBsaW5lIGNvdW50Ljxicj48YnI+PC9kaXY+PGRpdj5GaWxlLCB0ZXN0LnR4dCAo YXR0YWNoZWQgaGVyZSB3aXRoKSBjb3VsZCBiZSBtaXNzaW5nIGxhc3QgJnF1b3Q7bmV3IGxpbmUm cXVvdDsuPGJyPjxicj48L2Rpdj48ZGl2PlRoYW5rczxicj48L2Rpdj48ZGl2PlNldmE8YnI+PC9k aXY+PGRpdj48YnI+PGJyPjwvZGl2Pjxicj48L2Rpdj4NCg== --089e011607584a0c9f052f73875d-- --089e011607584a0ca5052f73875f Content-Type: application/x-gzip; name="test.txt.gz" Content-Disposition: attachment; filename="test.txt.gz" Content-Transfer-Encoding: base64 X-Attachment-Id: f_imi94hxj0 H4sICLvo/lYAA3Rlc3QudHh0ABWU2Q3DMAxD/zONJOscxzq8/whVUaAIEsemyMeYy7vBSlmsntMX AiDE9CKf8df7zA4ipO+ye6ICjlqE3r2ITxqU3qU7bMIet/oFvmE8uJvqtJSHvBEDyAEpuCJpiigl gZ9Ga/AjdFKlY46nd6NX1RdbDw8z3ZwnAs1/tef0ywNIT8brw8Jd0oNEq3hWdClkub6I/a9MmjhB gxeR36lJuxPTZyIl+aMdzA7l8fNOwJhgezGdwW4dXfliO4DUO6ovvcOGemVG7in1Pbfn8HL9Eby7 /vmVa3IeMtJJTKrb+/az23wQis/J7NcOslI/Br8poQbmqw+Pyj17UMbtuw7oCtr18Mb6Xs4xOlz+ 9oYDMH8OpQgKp/nGBW/Dl+8q1B7rVm8H1vEN6yrzWnLbD0kPN6R5f3k9qaWdDS7Foc4cMtFLG+aq 6oKpPU5N3pHKolPnLR8DpuZfluCGxAkjsA/WNI3wDSu5KwYz8q52FhSMa/0I/OjfQSyw970zy9i8 FbvaWAfRHx9lIKUpS/YbGkYvg9RnRTU7vQXSzRi+Xj2Pq7FTcKMNDi0DX6BdFWdvloxWCcTB8toA isc7O9cb+3ydEfCa3QNRbXm5vlPvxKM2VVpt+9NGCuUw5NvxNslYsFo+gkZbB1joWiAYX4JYirm3 N/ikSDZAAn0TPVHn+n8oElmkbFMg5lW5HVrP7k39O0JCFYR22sUMF+WoPo6D7O0bw0Ku4LPt+Mh2 pOBl0M9szlud6DXl7WBkY6mEeci0FyYdHlQhrG2Qnbcsfnf9vx6T+nj7Faf37kpxPpd4XdE9p2w/ D6Wb3h/VexfhXPRS7HzwKP8l/aPKoEvU+JTv5ZK4o4gWbrWILtsfmfd346QMA29R+Pt3P6GscQMM zpbU/BN412eF/0dl0BcU9LqMtvbeItsRCOSqfKmqW1tkGyGAtiPbEc/trj01PlSSDplO3S26feQV k7sSPUC+EUXqwjYYP9ILDqfwvluzJ+BuFS8eb6175MTWATi2n3c928h+oCDCflQFAAA= --089e011607584a0ca5052f73875f-- From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 02 16:40:09 2016 Received: (at 23190) by debbugs.gnu.org; 2 Apr 2016 20:40:09 +0000 Received: from localhost ([127.0.0.1]:49197 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1amSL3-0002Rk-1f for submit@debbugs.gnu.org; Sat, 02 Apr 2016 16:40:09 -0400 Received: from mail-qg0-f46.google.com ([209.85.192.46]:32776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1amSL1-0002RI-29 for 23190@debbugs.gnu.org; Sat, 02 Apr 2016 16:40:07 -0400 Received: by mail-qg0-f46.google.com with SMTP id j35so122051601qge.0 for <23190@debbugs.gnu.org>; Sat, 02 Apr 2016 13:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=Ez7GJZU9+1erMrw52cpAOHRzn2OwIKBNdsIXoFc0cfc=; b=ADoRXWD3H6ATVb1+E9lIhjkN5XVC9dA9N+TxMf79upfItLWMXf3U0J5lHvlDAtGAYu d4O7IVoXgHPC33uuNEVwLLuRoun343B5i3dAMDzNxT0Y9hGK/rxDsR5vyFwynmzELg7y m27V9AmYyOCk6fP2cN5O3UxztFTNCWeMfqL8cGqZNpyu9uFteZjcW+Hec3bAqKmZHrhE 2qqmIM2PSGsDrVgTCr4i0LwCT5/9JX+4fE6bNA2F12i3J4k3raYW98QEn2rzVTiXic9i hb7fZqQPFtLw3tLD7uqlw6O1TsDEcJIyuO7q2yen8E3GJvyBffArWmtvp2nctgL9qwh6 5EBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=Ez7GJZU9+1erMrw52cpAOHRzn2OwIKBNdsIXoFc0cfc=; b=JJcIiUoobsPV4kNrVPGfjN4gBVmsTzt8lhuth1qKkgxTjZc6YvYV8GndcqLhsuJ7kW YMzrjJjVeWlDZB7rFARMb5st4SIWKOe70uwjmO0MFUKfRDA9jtLsA2ZCjRb5zC+GP+hE cJ7M0Twhcc4jyCqQkPcN9umpncqLIDfd8U472DuYDnHv1Idg/F4oQ6jrXwj6qxw/Z5UL 65f2qblWF6jrcH4PDTYq/94+cmsBjuP3Ab0Z0DGpHIVYuCj7/n1Wc5SqeDL2bsU63IoN b8uI5IP/DnUp0ASVfYbwcaXLtFiTOXuan3RzdC4AWmzefFYF7lQU75eNEQUD/HT2XbP6 lk5g== X-Gm-Message-State: AD7BkJKGomU8ojHNG5j/mUcN5GAd9Ieuf3injvBD63GwHSH/4Jnz85OKeUnj+81S66BDSA== X-Received: by 10.140.101.145 with SMTP id u17mr228497qge.59.1459629601639; Sat, 02 Apr 2016 13:40:01 -0700 (PDT) Received: from disco.erlich.nygenome.org ([69.74.14.178]) by smtp.googlemail.com with ESMTPSA id f83sm8949343qkb.25.2016.04.02.13.40.00 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 02 Apr 2016 13:40:00 -0700 (PDT) Subject: Re: bug#23190: wc - Different output To: Seva Adari , 23190@debbugs.gnu.org References: From: Assaf Gordon Message-ID: <57002E20.3080504@gmail.com> Date: Sat, 2 Apr 2016 16:40:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 23190 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 (/) tags 23190 notabug close 23190 thanks Hello Seva, On 04/01/2016 06:02 PM, Seva Adari wrote: > I am not sure if this a bug or expected behavior! Here is different output > from each run variation of wc invocation: > wc -l test.txt Output: 20 > awk '{print $0}' /tmp/test.txt | wc -l Output: 21 > cut /tmp/test.txt -f1 | wc -l Output: 21 [...] > > File, test.txt (attached here with) could be missing last "new line". This is not a bug in 'wc', but the way it works (perhaps not intuitively): 'wc' does not count conceptual lines but the number of newline characters in the file. Since the last file does not have a newline character (ASCII 0x10) - it is not counted. The following will demonstrate: $ printf "hello" | wc -l 0 $ printf "hello\n" | wc -l 1 $ printf "a\nb\nc" | wc -l 2 And 'awk' indeed automatically adds a newline when using 'print', like so: $ printf "a\nb\nc" | awk '{print $0}' | wc -l 3 I'm therefore closing the bug, but discussion can continue by replying to this thread. regards, - assaf From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 07 17:21:13 2016 Received: (at 23190) by debbugs.gnu.org; 7 Apr 2016 21:21:13 +0000 Received: from localhost ([127.0.0.1]:53248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoHMX-0001q8-AL for submit@debbugs.gnu.org; Thu, 07 Apr 2016 17:21:13 -0400 Received: from mail-io0-f180.google.com ([209.85.223.180]:33642) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoHMV-0001pt-I0 for 23190@debbugs.gnu.org; Thu, 07 Apr 2016 17:21:11 -0400 Received: by mail-io0-f180.google.com with SMTP id o126so87292657iod.0 for <23190@debbugs.gnu.org>; Thu, 07 Apr 2016 14:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=9MkKloTDtvoC/6zQ9J+ACmpgrbr9ubAtyUaY62PRu74=; b=asABWNHlB/9Mt4GbktpVom4dmo+527EXf4qc5IdvM+EM8JfWc2cm0ff/0YHyc61NMu 9FJ99q6y5pxDmTTdbTe+5VnvB38lzU6KjcK+TxgmAq32O8hcXF6vqB8zBUt6cFIQ5S7K BwZZBqx8cR9DGVr1SMzADl4ziPz0EcWSaAAcOPA3PGZd0/brnQi0rgvYJJUMjwSqUnC1 SktoAKPe2O6lq4TUzwLL1ZukEmM3Ry5sIjcXp/q6ym3hQc6LpkpjGYsrxF1GSXWfixMr XO9/GFslZh13jHhE9DIAghZRBIQsDVJXEGvN3CpaK+4vIv0Y2TuBE5EKePdEuH42Omtc e8/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=9MkKloTDtvoC/6zQ9J+ACmpgrbr9ubAtyUaY62PRu74=; b=MpLqihuhHxzVX+gdfmSvfzCQnGUX6kgmaFZ0be5D9XiNMXv/XDygrE1/L2u1uMTrSe rHGXao6KYxelerxHXxzpP3SDfqK+a7irAnH8o0XNWAX8Opj03psU92gwhZzWtfrv95Eh rGMS/paKNNO9tvzKycAMNPX/HDSc8fcdTvoJvV/vJBj+EFtpg9YcilaBWXaE2mZ5/fdz ZcLwMBt08PkvXy4bDwRcY5jJGDayma/J9NmwTqwE0Re08Im6541SlRuaXmT+ScAK3Yzp s219XueJSxe5XwPc3cx9EGUXdrQ8NmB9Z61jrpT4PNPpaH/FDLSVc3lFkwuGiigpfNu0 cJRw== X-Gm-Message-State: AD7BkJIbIn1TC4mmEGrP7+EaBnaAC9WmXPiGaOLaUhpYIHHHeHtyz+BsBDPPw9e0p1tFxRxPt5lgcYlH/dKgXg== MIME-Version: 1.0 X-Received: by 10.107.135.74 with SMTP id j71mr6160092iod.133.1460064065923; Thu, 07 Apr 2016 14:21:05 -0700 (PDT) Received: by 10.107.6.154 with HTTP; Thu, 7 Apr 2016 14:21:05 -0700 (PDT) In-Reply-To: <57002E20.3080504@gmail.com> References: <57002E20.3080504@gmail.com> Date: Thu, 7 Apr 2016 17:21:05 -0400 Message-ID: Subject: Re: bug#23190: wc - Different output From: Seva Adari To: Assaf Gordon Content-Type: multipart/alternative; boundary=001a113f9218ffb221052feba790 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 23190 Cc: 23190@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: -0.7 (/) --001a113f9218ffb221052feba790 Content-Type: text/plain; charset=UTF-8 Thanks for the explanation! On Sat, Apr 2, 2016 at 4:40 PM, Assaf Gordon wrote: > tags 23190 notabug > close 23190 > thanks > > Hello Seva, > > On 04/01/2016 06:02 PM, Seva Adari wrote: > >> I am not sure if this a bug or expected behavior! Here is different output >> from each run variation of wc invocation: >> wc -l test.txt Output: 20 >> awk '{print $0}' /tmp/test.txt | wc -l Output: 21 >> cut /tmp/test.txt -f1 | wc -l Output: 21 >> > [...] > >> >> File, test.txt (attached here with) could be missing last "new line". >> > > This is not a bug in 'wc', but the way it works (perhaps not intuitively): > > 'wc' does not count conceptual lines but the number of newline characters > in the file. > Since the last file does not have a newline character (ASCII 0x10) - it is > not counted. > > The following will demonstrate: > > $ printf "hello" | wc -l > 0 > $ printf "hello\n" | wc -l > 1 > $ printf "a\nb\nc" | wc -l > 2 > > And 'awk' indeed automatically adds a newline when using 'print', like so: > > $ printf "a\nb\nc" | awk '{print $0}' | wc -l > 3 > > > I'm therefore closing the bug, but discussion can continue by replying to > this thread. > > regards, > - assaf > > --001a113f9218ffb221052feba790 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks for the explanation!
=
On Sat, Apr 2, 2016 at 4:40 PM, Assaf Gordon= <assafgordon@gmail.com> wrote:
tags 23190 notabug
close 23190
thanks

Hello Seva,

On 04/01/2016 06:02 PM, Seva Adari wrote:
I am not sure if this a bug or expected behavior! Here is different output<= br> from each run variation of wc invocation:
=C2=A0 =C2=A0 =C2=A0wc -l test.txt=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Output: 20
=C2=A0 =C2=A0 =C2=A0awk '{print $0}' /tmp/test.txt | wc -l=C2=A0 = =C2=A0 =C2=A0 =C2=A0Output: 21
=C2=A0 =C2=A0 =C2=A0cut /tmp/test.txt -f1 | wc -l=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Output: 21
[...]

File, test.txt (attached here with) could be missing last "new line&qu= ot;.

This is not a bug in 'wc', but the way it works (perhaps not intuit= ively):

'wc' does not count conceptual lines but the number of newline char= acters in the file.
Since the last file does not have a newline character (ASCII 0x10) - it is = not counted.

The following will demonstrate:

=C2=A0 =C2=A0$ printf "hello" | wc -l
=C2=A0 =C2=A00
=C2=A0 =C2=A0$ printf "hello\n" | wc -l
=C2=A0 =C2=A01
=C2=A0 =C2=A0$ printf "a\nb\nc" | wc -l
=C2=A0 =C2=A02

And 'awk' indeed automatically adds a newline when using 'print= ', like so:

=C2=A0 =C2=A0$ printf "a\nb\nc" | awk '{print $0}' | wc -= l
=C2=A0 =C2=A03


I'm therefore closing the bug, but discussion can continue by replying = to this thread.

regards,
=C2=A0- assaf


--001a113f9218ffb221052feba790-- From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 27 18:11:22 2018 Received: (at control) by debbugs.gnu.org; 27 Oct 2018 22:11:22 +0000 Received: from localhost ([127.0.0.1]:45941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGWnh-0006vS-On for submit@debbugs.gnu.org; Sat, 27 Oct 2018 18:11:21 -0400 Received: from mail-it1-f178.google.com ([209.85.166.178]:35487) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGWng-0006vG-Oi for control@debbugs.gnu.org; Sat, 27 Oct 2018 18:11:20 -0400 Received: by mail-it1-f178.google.com with SMTP id p64-v6so5609629itp.0 for ; Sat, 27 Oct 2018 15:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:message-id:date:user-agent:mime-version:content-language :content-transfer-encoding; bh=bpSek6+wPBDRCAs0KhN+idKA0MwSb9HX4iD+s5fZXhg=; b=nteq3MwwmHAv/RkSFakCj7RfbTf/dHA0xtDGuV4Tg5HjE5sCrKG97ce01V305PMY57 V7eMDW6Haf4ay9Mjd4InkHryoVFDODIScKByxi8h754oWBlyIKSa5ZGyNF8xevclBbsf Y+A174WMoMtNORjKAGPwMRLvJ5iozwTHaLNq7ieILBxzcgmLzbXCx8hYe4v9U2NP7UVr 5B/itdFzgEJb7/CeMTyDwTF3NONNaQHkX3d7u0bJ3Q+8YDpc5rrvbu89NGGu5+hHAr8r i1pQV84rtl178gmnim5Pka+IEHWcGF7IkugTRx0IYYdpRW4VaiMDNfKiyI5EFkNSyMtK MwTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=bpSek6+wPBDRCAs0KhN+idKA0MwSb9HX4iD+s5fZXhg=; b=Lx9bNllsQWFXpDpVLbcUuIo8sR4KWWfvrRth8/6y+RmwiQL7lnz/qgD2UO4pDS5qx8 Ybp8VPXsY7s4mrN8YH92y0+1e0Ku67d7FAwletCjopq7Eur5OVWFT+PNdNeSSFWjGJTI V/iatUcKnGYNQjG9B7Kln3ycrZbolUZSlFx3zYq7vjty5SRum8tpb9s1ob7Au0dA1oVQ 6Do/qdSUF5h2RYVHT9n4mJ4OIwYUZWqrmM0sr+Fq652Blu7oBMiS5YYUqdmS0EbR6avw Vt/GZhkwhutiETHUdspMNkMz8YaFNkpUt1IbEPWpvwpkqBeVcUJqqtqX86v/lU2mfSpK aQqA== X-Gm-Message-State: AGRZ1gL1zkkFUSkWK/RALtQjoO1g9i/fr5e4y1aUO8A2bgZv/YLEHc58 Y51rCWL63dYm0nPwZdBltPz60uEU X-Google-Smtp-Source: AJdET5cs8Mc0P7gnme1vWMGjPBOmIWd/tLg6CJ4D+AAbwro1a+ddFbSHYFkgZcRXDuH0n4YrDJQpnw== X-Received: by 2002:a24:c503:: with SMTP id f3-v6mr5226776itg.135.1540678274782; Sat, 27 Oct 2018 15:11:14 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id m6-v6sm4009060ioh.35.2018.10.27.15.11.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 15:11:13 -0700 (PDT) To: control@debbugs.gnu.org From: Assaf Gordon Message-ID: Date: Sat, 27 Oct 2018 16:11:12 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: tags 23190 notabug close 23190 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (assafgordon[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.166.178 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.178 listed in wl.mailspike.net] 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control 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 (+) tags 23190 notabug close 23190 From unknown Thu Sep 11 11:56:31 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 25 Nov 2018 12:24:12 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator