* Using cat, head, tail on binary files
@ 2001-11-16 13:11 Erik Sobel
2001-11-16 15:29 ` Gerald Villemure
2001-11-27 7:16 ` Erik Sobel
0 siblings, 2 replies; 4+ messages in thread
From: Erik Sobel @ 2001-11-16 13:11 UTC (permalink / raw)
To: cygwin
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using cat, head, tail on binary files
2001-11-16 13:11 Using cat, head, tail on binary files Erik Sobel
@ 2001-11-16 15:29 ` Gerald Villemure
2001-11-27 7:33 ` Gerald Villemure
2001-11-27 7:16 ` Erik Sobel
1 sibling, 1 reply; 4+ messages in thread
From: Gerald Villemure @ 2001-11-16 15:29 UTC (permalink / raw)
To: cygwin, Erik Sobel
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.sobel@alphatech.com>
To: <cygwin@cygwin.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@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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using cat, head, tail on binary files
2001-11-16 15:29 ` Gerald Villemure
@ 2001-11-27 7:33 ` Gerald Villemure
0 siblings, 0 replies; 4+ messages in thread
From: Gerald Villemure @ 2001-11-27 7:33 UTC (permalink / raw)
To: cygwin, Erik Sobel
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.sobel@alphatech.com>
To: <cygwin@cygwin.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@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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Using cat, head, tail on binary files
2001-11-16 13:11 Using cat, head, tail on binary files Erik Sobel
2001-11-16 15:29 ` Gerald Villemure
@ 2001-11-27 7:16 ` Erik Sobel
1 sibling, 0 replies; 4+ messages in thread
From: Erik Sobel @ 2001-11-27 7:16 UTC (permalink / raw)
To: cygwin
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-11-27 15:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-16 13:11 Using cat, head, tail on binary files Erik Sobel
2001-11-16 15:29 ` Gerald Villemure
2001-11-27 7:33 ` Gerald Villemure
2001-11-27 7:16 ` Erik Sobel
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).