From unknown Fri Jun 20 07:09:28 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#17384 <17384@debbugs.gnu.org> To: bug#17384 <17384@debbugs.gnu.org> Subject: Status: "bug" in the Unix "cat" command Reply-To: bug#17384 <17384@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:09:28 +0000 retitle 17384 "bug" in the Unix "cat" command reassign 17384 coreutils submitter 17384 Peter Rowat severity 17384 normal tag 17384 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Thu May 01 15:11:12 2014 Received: (at submit) by debbugs.gnu.org; 1 May 2014 19:11:12 +0000 Received: from localhost ([127.0.0.1]:47701 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WfwNz-00084r-Tp for submit@debbugs.gnu.org; Thu, 01 May 2014 15:11:12 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38108) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wfw55-0007Vx-8C for submit@debbugs.gnu.org; Thu, 01 May 2014 14:51:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wfw4p-00037q-OY for submit@debbugs.gnu.org; Thu, 01 May 2014 14:51:33 -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,HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:36937) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wfw4p-00037k-LY for submit@debbugs.gnu.org; Thu, 01 May 2014 14:51:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wfw4h-0008M3-Aq for bug-coreutils@gnu.org; Thu, 01 May 2014 14:51:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wfw4Y-00031v-JN for bug-coreutils@gnu.org; Thu, 01 May 2014 14:51:15 -0400 Received: from iport-acv2-out.ucsd.edu ([132.239.0.174]:42128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wfw4Y-0002bA-8R for bug-coreutils@gnu.org; Thu, 01 May 2014 14:51:06 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EAPeWYlOE7/kU/2dsb2JhbABagwa+PYhVFnSDRIlzlnOtIYVuF45vgw6BFQSKBqIXg1M X-IPAS-Result: Av8EAPeWYlOE7/kU/2dsb2JhbABagwa+PYhVFnSDRIlzlnOtIYVuF45vgw6BFQSKBqIXg1M X-IronPort-AV: E=Sophos;i="4.97,966,1389772800"; d="scan'208,217";a="80249728" Received: from act-bufferout-a1.ucsd.edu ([132.239.249.20]) by iport-acv2-out.ucsd.edu with ESMTP; 01 May 2014 11:50:43 -0700 Received: from client64-36.sdsc.edu (client64-36.sdsc.edu [132.249.64.36]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by act-bufferout-a1.ucsd.edu (Postfix) with ESMTPS id B1515EA66A for ; Thu, 1 May 2014 11:50:42 -0700 (PDT) From: Peter Rowat Content-Type: multipart/alternative; boundary="Apple-Mail=_71BE3CC5-EE35-474C-BF2D-F8C76D13302B" Subject: "bug" in the Unix "cat" command Message-Id: <850CF85B-40AA-4F35-8A22-C5B0C613C5BF@pelican.ucsd.edu> Date: Thu, 1 May 2014 11:50:38 -0700 To: bug-coreutils@gnu.org Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) X-Mailer: Apple Mail (2.1874) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 01 May 2014 15:11:08 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -5.0 (-----) --Apple-Mail=_71BE3CC5-EE35-474C-BF2D-F8C76D13302B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Hello Gnu folks, I had 3 files matching =93isi.*.02p0: wc -l isi.*.02p0 20000 isi.R.0400.02p0 15500 isi.Ra.0400.02p0 15600 isi.Rb.0400.02p0 51100 total I wanted to combine them into one big file, while knowing *not* to cat = into a file with same name as an original file, I did this: cat isi.*.02p0 >isi.Rall.0400.02p0 But it never returned!!=20 By the time I hit Ctrl-C, the file isi.Rall.0400.02p0 was already 3000 = times bigger than the biggest of the original files. A hidden loop was made.=20 Because the destination file was created before concatenation started, = it became a match for the pattern "isi.*.02p0=94. It might be worth adding a warning about this on the cat man-page ?? Cheers, =97 Peter Rowat= --Apple-Mail=_71BE3CC5-EE35-474C-BF2D-F8C76D13302B Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 Hello = Gnu folks,

  I had 3 files  matching = =93isi.*.02p0:

wc -l isi.*.02p0
   20000 isi.R.0400.02p0
   15500 isi.Ra.0400.02p0
   15600 = isi.Rb.0400.02p0
   51100 total

I wanted = to combine them into one big file, while knowing *not* to cat into a = file with same name as an original file,
 I did = this:

cat isi.*.02p0 >isi.Rall.0400.02p0


But = it never returned!! 
By the time I hit Ctrl-C, the = file isi.Rall.0400.02p0 was already 3000 times bigger = than the biggest of the original files.

A = hidden loop was made. 

Because the = destination file was created before concatenation started, it became a = match for the
pattern "isi.*.02p0=94.

It = might be worth adding a warning about this on the  cat man-page = ??

Cheers,

=97 Peter = Rowat
= --Apple-Mail=_71BE3CC5-EE35-474C-BF2D-F8C76D13302B-- From debbugs-submit-bounces@debbugs.gnu.org Thu May 01 16:53:02 2014 Received: (at 17384) by debbugs.gnu.org; 1 May 2014 20:53:02 +0000 Received: from localhost ([127.0.0.1]:47725 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WfxyX-0002U2-Vk for submit@debbugs.gnu.org; Thu, 01 May 2014 16:53:02 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:61882) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WfxyV-0002Td-7p for 17384@debbugs.gnu.org; Thu, 01 May 2014 16:53:00 -0400 Received: from [192.168.1.20] (p5084F89F.dip0.t-ipconnect.de [80.132.248.159]) by mrelayeu.kundenserver.de (node=mreue005) with ESMTP (Nemesis) id 0LsMjU-1Wqs722q8u-011ydF; Thu, 01 May 2014 22:52:52 +0200 Message-ID: <5362B424.8090500@bernhard-voelker.de> Date: Thu, 01 May 2014 22:52:52 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Peter Rowat , 17384@debbugs.gnu.org Subject: Re: bug#17384: "bug" in the Unix "cat" command References: <850CF85B-40AA-4F35-8A22-C5B0C613C5BF@pelican.ucsd.edu> In-Reply-To: <850CF85B-40AA-4F35-8A22-C5B0C613C5BF@pelican.ucsd.edu> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:2Az2gmlAAUssPLyiDCA3IyJBSjyTiEMShMQygNKF1hf Pefa4YCg1rN3J6ctmOqsB/6LIOVCYMPPc+uO0oIFR++7nAepfm A5ViX5zSeOh9rmPWlGHKy7LHxFkIcmlT15Jh7tMrfs5HqdoGBr Ncw0ET/7g4JbxXUo1cdcXpDq55SmNXYPi5CLmH+ZMl3+xThDqv xcixhZQvwMn2G/3bfixzG1ZNVXP5/32J89JqPP5+o6rc/8vWfF mxXmjfVOu1DRQQbGOG8z29idJcVHyXUsRYMo7KANlAEckXurOr hBcEBkpQPrE2CFdkoEiXHEqPXK7ZuvwlkfdVqe+0hVTmAwOXSJ MSaEUtLzHKtDCfQHHdYxyF2SHn9iaZ/cpxmQj5XSj X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 17384 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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.0 (/) tags 17384 + moreinfo thanks On 05/01/2014 08:50 PM, Peter Rowat wrote: > Hello Gnu folks, > > I had 3 files matching “isi.*.02p0: > > wc -l isi.*.02p0 > 20000 isi.R.0400.02p0 > 15500 isi.Ra.0400.02p0 > 15600 isi.Rb.0400.02p0 > 51100 total > > I wanted to combine them into one big file, while knowing *not* to cat into a file with same name as an original file, > I did this: > > cat isi.*.02p0 >isi.Rall.0400.02p0 > > > But it never returned!! > By the time I hit Ctrl-C, the file isi.Rall.0400.02p0 was already 3000 times bigger than the biggest of the original files. > > A hidden loop was made. > > Because the destination file was created before concatenation started, it became a match for the > pattern "isi.*.02p0”. > > It might be worth adding a warning about this on the cat man-page ?? Thanks for the bug report. However I cannot reproduce the problem. On my system (openSUSE-13.1), the output file is created with exactly the 51100 lines as expected: $ seq 20000 > isi.R.0400.02p0 $ seq 15500 > isi.Ra.0400.02p0 $ seq 15600 > isi.Rb.0400.02p0 $ wc -l isi.*.02p0 20000 isi.R.0400.02p0 15500 isi.Ra.0400.02p0 15600 isi.Rb.0400.02p0 51100 total $ src/cat isi.*.02p0 >isi.Rall.0400.02p0 $ wc -l isi.*.02p0 20000 isi.R.0400.02p0 15500 isi.Ra.0400.02p0 51100 isi.Rall.0400.02p0 15600 isi.Rb.0400.02p0 102200 total If the output file had previously existed (so that the file name globbing would let it match the pattern), then cat(1) would have complained: $ src/cat isi.*.02p0 >isi.Rall.0400.02p0 src/cat: isi.Rall.0400.02p0: input file is output file That means that on your system a) the shell opened the output file before doing the pattern matching, and b) cat(1) was unable to detect that the output file is the same as the input file. As that check is included in GNU coreutils' cat(1) since day one, this issue is not a matter of an outdated version of cat(1). What system are you using (OS, file system type, shell, shell version, and finally 'cat --version')? Can you confirm that the previously non-existing output file was matched by the pattern using "set -x" before issuing the command? When the output file did not previously exist: $ ( set -x; src/cat isi.*.02p0 >isi.Rall.0400.02p0 ) + src/cat isi.R.0400.02p0 isi.Ra.0400.02p0 isi.Rb.0400.02p0 When the output file already exists: $ ( set -x; src/cat isi.*.02p0 >isi.Rall.0400.02p0 ) + src/cat isi.R.0400.02p0 isi.Ra.0400.02p0 isi.Rall.0400.02p0 isi.Rb.0400.02p0 src/cat: isi.Rall.0400.02p0: input file is output file Thanks & have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Fri May 02 09:16:48 2014 Received: (at 17384) by debbugs.gnu.org; 2 May 2014 13:16:48 +0000 Received: from localhost ([127.0.0.1]:48126 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WgDKZ-0003D4-PM for submit@debbugs.gnu.org; Fri, 02 May 2014 09:16:48 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:55639) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WgDKW-0003Ck-2Z for 17384@debbugs.gnu.org; Fri, 02 May 2014 09:16:45 -0400 Received: from [10.0.4.15] (gw.camline.com [62.153.148.194]) by mrelayeu.kundenserver.de (node=mreue104) with ESMTP (Nemesis) id 0MMFUT-1WncN73i6H-0086pY; Fri, 02 May 2014 15:16:05 +0200 Message-ID: <53639A94.20001@bernhard-voelker.de> Date: Fri, 02 May 2014 15:16:04 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Peter Rowat , 17384@debbugs.gnu.org Subject: Re: bug#17384: "bug" in the Unix "cat" command References: <850CF85B-40AA-4F35-8A22-C5B0C613C5BF@pelican.ucsd.edu> <5362B424.8090500@bernhard-voelker.de> In-Reply-To: <5362B424.8090500@bernhard-voelker.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:VJkaYmCBNet8TXUENKfrPFpL2FbpGlyd/c6Nhuevey+ 9W19YUsL/LgPQsXSABifhGEBaFQLwUDNpY/sLTL7ia07CsS0Qb +6Y3+EJBmK6JbAxfCFNltzMD2vUm2uP7smkoFGfxN3T7ZsJuNi 70kyjQyKH5pIs3MCeE7oQRdYzIZsT3aJgBzb4hjru9FX1bHqqf HD8vAM6QnjYsTdAsQ1LiXOPcNlh4Jt60Kp2SIK8fRybpprKzyD qU/w/GZE59AtQm4fdoZD74HVAUP44oKmrDu5tBtemyCDYAJdST aoL8OO2cawAaEL0/gekHBrq2ppu1QMnSF+NOjrGiAsEELZkxOn F6eKk1hteC7n9UF2fdZcXGHWLphcj67+ONpArrRPO X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 17384 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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.0 (/) tags 17384 notabug close 17384 stop On 05/01/2014 10:52 PM, Bernhard Voelker wrote: > If the output file had previously existed (so that the file name > globbing would let it match the pattern), then cat(1) would have > complained: > > $ src/cat isi.*.02p0 >isi.Rall.0400.02p0 > src/cat: isi.Rall.0400.02p0: input file is output file > > That means that on your system > a) the shell opened the output file before doing the pattern matching, > and b) cat(1) was unable to detect that the output file is the same > as the input file. > As that check is included in GNU coreutils' cat(1) since day one, > this issue is not a matter of an outdated version of cat(1). > > What system are you using (OS, file system type, shell, shell version, > and finally 'cat --version')? As confirmed in private email, the system was "Mac OS X 10.9.2 (Mavericks)" ... and the OP was using the Apple version of 'cat'. I'm therefore marking this as not a bug and closing it. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 02 13:51:44 2014 Received: (at control) by debbugs.gnu.org; 2 Jun 2014 17:51:44 +0000 Received: from localhost ([127.0.0.1]:41203 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WrWOZ-0008TT-SU for submit@debbugs.gnu.org; Mon, 02 Jun 2014 13:51:44 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:55023) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WrWOT-0008TB-Mf for control@debbugs.gnu.org; Mon, 02 Jun 2014 13:51:38 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id B8D72A6003F for ; Mon, 2 Jun 2014 10:51:27 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vd7c9QQNynpL for ; Mon, 2 Jun 2014 10:51:19 -0700 (PDT) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 45677A60028 for ; Mon, 2 Jun 2014 10:51:19 -0700 (PDT) Message-ID: <538CB997.5030706@cs.ucla.edu> Date: Mon, 02 Jun 2014 10:51:19 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: control@debbugs.gnu.org Subject: cleaning up some coreutils bugs Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -3.0 (---) tags 17384 notabug close 17384 tags 17553 notabug close 17553 forcemerge 16530 16955 From unknown Fri Jun 20 07:09:28 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 01 Jul 2014 11:24:05 +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