delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/11/27/10:35:18

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <00f401c17759$708343d0$0200000a@dyn.ik.ca>
From: "Gerald Villemure" <GVillemure AT ik DOT ca>
To: <cygwin AT cygwin DOT com>, "Erik Sobel" <erik DOT sobel AT alphatech DOT com>
References: <4 DOT 3 DOT 2 DOT 7 DOT 2 DOT 20011127095652 DOT 00b92960 AT mail DOT alphatech DOT com>
Subject: Re: Using cat, head, tail on binary files
Date: Tue, 27 Nov 2001 16:37:31 +0100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

Use the dd command to work with binary files.

For example:
dd if=foo of=foo.part1 bs=1kD count=10

This will create a file called 'foo.part1' with the first 10000 bytes

If you want part2 one way is:
dd if=foo of=foo.part2 bs=1kD skip=10

Hope this helps
Gerald

----- Original Message -----
From: "Erik Sobel" <erik DOT sobel AT alphatech DOT com>
To: <cygwin AT cygwin DOT com>
Sent: Tuesday, November 27, 2001 4:16 PM
Subject: Using cat, head, tail on binary files


> 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 AT alphatech DOT 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/

- Raw text -


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