delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/08/29/04:46:43

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Fri, 29 Aug 2003 10:46:11 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: awk / sed - trouble with CR character
Message-ID: <20030829084611.GB27016@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <3E2D8043936AD611AF7D00508B5E9F4B4D3E4D AT server3 DOT mobilecom DOT com>
Mime-Version: 1.0
In-Reply-To: <3E2D8043936AD611AF7D00508B5E9F4B4D3E4D@server3.mobilecom.com>
User-Agent: Mutt/1.4.1i

On Mon, Aug 25, 2003 at 05:12:22PM -0400, Cary Lewis wrote:
> I have a binary file, with 8 lines of ascii at the top, and then a binary
> line
> 
> The binary line contains the 0x0d.
> 
> E.g.
> 
> $ od -tx1 a
> 0000000 31 0a 32 0a 33 0a 34 0a 35 0a 36 0a 37 0a 38 0a
> 0000020 31 32 33 0d 0a 39 39 39 0a 34 35 36 0a
> 0000035
> 
> $ cat a
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 123
> 999
> 456
> 
> If I try to to use sed to eliminate the first 8 lines (or awk)
> 
> then the CR character is dropped
> 
> e.g.
> 
> sed '1,8d' a | od -tx1 yields:
> 
> $ sed  '1,8d' a|od -tx1
> 0000000 31 32 33 0a 39 39 39 0a 34 35 36 0a
> 0000014
> 
> Is there a way to make this work in Cygwin.

Not with sed, which is treating all input as text.  But it should work
with gawk.  I just tried it by myself, using the latest gawk-3.1.3:

$ awk '{ if ( NR > 8 ) print $0; }' < a|od -tx1
0000000 31 32 33 0d 0a 39 39 39 0d 0a 34 35 36 0d 0a
0000017

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

--
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/

- Raw text -


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