delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/07/23/12:36:30

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Reply-To: <jtr AT mitre DOT org>
From: "Jeffry T Ross" <jtr AT mitre DOT org>
To: <cygwin AT sourceware DOT cygnus DOT com>
Subject: RE: Cat and Head Problems with Binary Files
Date: Fri, 23 Jul 1999 12:35:29 -0400
Message-ID: <000e01bed529$6000e780$0f8e5381@Toeplitz.mitre.org>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0
Importance: Normal
In-Reply-To: <4.1.19990722175718.00de9820@mailhost.teknowledge.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3

Randy

I thought the suggestion to use dd was a good, although a bit excessive
when one only wants to move bytes from a file to a pipe without any
conversion. So I tried it:

dd if=test1 > test2
test1 was 1296 bytes and test2 became 1301 bytes.

So then I tried dd directly to a file.
dd if=test1 of=test2
this worked fine.

So now I don't suspect cat but the piping and redirection.
The question is how does cygwin implement it's piping and redirection?
Is this problem imposed by the underlying WIN/DOS or is it a bug in BASH?

The pipe shouldn't be trying to interpret the data going through it.
That's the job of the process at the end of the pipe, be it the terminal
or another program.



							jtr AT mitre DOT org
 

-----Original Message-----
From: Randall Schulz [mailto:rschulz AT teknowledge DOT com]
Sent: Thursday, July 22, 1999 9:24 PM
To: jtr AT mitre DOT org; cygwin AT sourceware DOT cygnus DOT com
Subject: RE: Cat and Head Problems with Binary Files


JTR,

Who ever said head and cat were the way to deal with a problem like this?
Head may have a -c option, but it's indended use is to capture a certain
number of *lines* of the beginning of a file.

For what you want to do, you should try dd. It's tailor made for this sort
of thing. I knows not of lines, but every other manner of file copying
based on regular file subdivisions is its forte. It can also perform some
transformations such as case conversion, character code translation, byte
swapping, etc.

Check it out!

Randy Schulz
Teknowledge Corp.
Palo Alto, CA USA


At 05:49 PM 7/22/99 , Jeffry T Ross wrote:
>Who ever said that cat and head are textutils?
>On the Unix side of the world they're commonly used
>on binary files.  If you have a 10gig file of binary
>data, what the easiest way to get a 10k chunk?
>
>How about: head -c 10000 bigfile > littlefile
>
>This works in Unix because Unix thinks all files are
>binary, and that's because all files are binary.  The
>notion of text files is a bogus limitation imposed by
>Microsoft.
>
>Is there a reason why having cat treat all files as binary
>would cause erroneous performance when cat was used on a
>file you'd consider to be text?
>
>
>Thanks,
>jtr AT mitre DOT org


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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