delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/10/07/11:33:19

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <4ACCB4AE.8030409@freesbee.fr>
Date: Wed, 07 Oct 2009 17:33:02 +0200
From: =?ISO-8859-1?Q?Vincent_Rivi=E8re?= <vincent DOT riviere AT freesbee DOT fr>
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Additional carriage return added by cygwin commands to DOS text files
References: <loom DOT 20091007T161054-245 AT post DOT gmane DOT org> <4ACCB085 DOT 3070304 AT freesbee DOT fr>
In-Reply-To: <4ACCB085.3070304@freesbee.fr>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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

> I experienced the same issue with the "cat" command, and unfortunately I 
> didn't find any transparent solution :-(

However a non-transparent hack is to use first a text filter then pipe 
its output to the original command. The filter opens the file in 
textmode so it gets rid of the CR. Then, as expected, no CR are present 
in the pipe. Then normal CRs are added in the resulting file when it is 
written on disk.

The "more" command is a good choice for such a filter, because its pager 
functionality is disabled when it writes to a pipe, so it acts as a 
simple repeater in textmode: exactly what we need.

$ more test1 |grep -U -E 'a|b' > test2
$ xxd test2
0000000: 6161 610d 0a62 6262 0d0a                 aaa..bbb..

The result is correct.

-- 
Vincent Rivière

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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