This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem concating (>>) to a large file


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]