delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/05/25/04:17:46

X-Spam-Check-By: sourceware.org
Message-ID: <46569B8B.1C15A76E@dessent.net>
Date: Fri, 25 May 2007 01:17:15 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: Peter Milne <peter DOT milne AT netspeed DOT com DOT au>
CC: cygwin AT cygwin DOT com
Subject: Re: problem concating (>>) to a large file
References: <001201c79ea3$4d82bce0$8500a8c0 AT RUSNAK>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Peter Milne wrote:

> I have a large file, let's call it A.  I want to stick the contents of a
> small file (let's call it B) onto the end of A.
> 
> Until recently in cygwin I could just type:
> 
>             cat B >> A
> 
> and it did exactly what I wanted.
> 
> Now though, presumably because A has gotten so large, when I do the above
> command the contents of file B get copied onto the front of file A rather
> than onto its end.
> 
> I assume that A has become sufficiently large that a 64-bit file offset is
> needed to properly address it and that >> doesn't currently support this.
> If so this certainly seems like a short coming, perhaps even a bug.
> 
> I updated my version of cygwin to the latest version but this didn't help.
> 
> Is there a fix or workaround?

I think there is a newlib bug (or maybe it's a Cygwin bug) where
stdin/stdout start off opened in 32 bit mode.  I'm not sure of the
details, and all I know about it is from observing that Eric Blake has
been working on compensating for this dilemma in gnulib as it seems to
cause problems seeking in some circumstances.

Anyway, you can achieve what you want with dd without the extra copy
step and without using stdin/stdout redirection and with the extra bonus
of being able to specify the Windows-optimal 64k block size (although
since you said B is small it shouldn't matter much):

dd if=B of=A bs=64k conv=notrunc oflag=append

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019