public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Erik Sobel <erik.sobel@alphatech.com>
To: cygwin@cygwin.com
Subject: Using cat, head, tail on binary files
Date: Tue, 27 Nov 2001 07:16:00 -0000	[thread overview]
Message-ID: <4.3.2.7.2.20011127095652.00b92960@mail.alphatech.com> (raw)
Message-ID: <20011127071600.vFJaZ2tsOua8yrs8AEurIikQDMug2DKOwjTkR4Zwxck@z> (raw)

What is the trick to getting cat, head, and tail to work correctly with 
binary files under WinNT?  I tried setting the CYGWIN environment variable 
to "binmode" as recommended by the documentation.  This got things closer 
to working but it's still not right.

Example:  given a binary file named foo of size 10000 bytes
CYGWIN=tty
head -c50 foo > foo.part1              # got 23 bytes from foo
tail -c1000 foo > foo.part2             # got 648 bytes from foo
cat foo.part1 foo.part2 > new_foo  # is not the sum of the two input file sizes

CYGWIN=binmode
head -c50 foo > foo.part1              # got 58 bytes from foo
tail -c1000 foo > foo.part2             # got 1046 bytes from foo
cat foo.part1 foo.part2 > new_foo  # is not the sum of the two input file sizes

cat foo foo > foo2  # is not twice the size of foo

Any suggestions would be appreciated.

Thanks,
Erik
----------------------------------------------------------------------------------------------------------
Erik Sobel
esobel@alphatech.com
----------------------------------------------------------------------------------------------------------


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

             reply	other threads:[~2001-11-27  7:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-16 13:11 Erik Sobel [this message]
2001-11-16 15:29 ` Gerald Villemure
2001-11-27  7:33   ` Gerald Villemure
2001-11-27  7:16 ` Erik Sobel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4.3.2.7.2.20011127095652.00b92960@mail.alphatech.com \
    --to=erik.sobel@alphatech.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).