delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/10/21/14:09:30

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: RE: Problem with the dos2unix command
Date: Sun, 21 Oct 2007 10:09:03 -0400
Message-ID: <31DDB7BE4BF41D4888D41709C476B657068AB735@NIHCESMLBX5.nih.gov>
In-Reply-To: <20071021094558.2392@blackhawk>
References: <AB5E58B87EB73C46A38073D8F459F11335B8D2 AT dataspheresrv01> <31DDB7BE4BF41D4888D41709C476B657068AB72D AT NIHCESMLBX5 DOT nih DOT gov> <20071021094558 DOT 2392 AT blackhawk>
From: "Buchbinder, Barry (NIH/NIAID) [E]" <BBuchbinder AT niaid DOT nih DOT gov>
To: <cygwin AT cygwin DOT com>, "d.henman" <dhenman AT gmail DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id l9LI9Fu3014302

From: d.henman, Sent: Saturday, October 20, 2007 8:46 PM
> Buchbinder, Barry (NIH/NIAID) [E] <BBuchbinder AT niaid DOT nih DOT gov> wrote:
> > From: Patrick Monnerat; Sent: Wednesday, October 17, 2007 7:00 AM
> > > I'm trying to convert a \r\n line-ending file to unix style, but 
> > > this file has some lines with their last character being \r (i.e.:

> > > the sequence of binary bytes is ...\r\r\n...)
> > > 
> > > Using dos2unix to convert it strips both \r, resulting in a byte 
> > > sequence ...\n...
> > > 
> > > This seems to me a bug. I need the trailing \r in the file as a 
> > > normal character, not being part of the line ending.
> > 
> > For the record, shouldn't the following work?
> > 
> > sed -i -e 's/\r$//' file1, file2, ...
>
> As long as your dealing with a know ascii text file, it Looks good,
except
> it will only work for the first line unless you sed's global option,
'g'.
> I don't thing the -i is necessary either...
> 
>  sed -i -e 's/\r$//g' file1, file2, ...

The -i option edits the files "in place", and brings in the -s option,
which
keeps sed from catenating the files together.

I understand the g flag as making global per line, not file, and the $
at the
end of the pattern.  If sed has some sort mode that allows \n to be in
the
middle of a pattern, that could be different but I am totally unfamiliar
with
that (and not feeling like checking) so couldn't comment.

But in any case, I could be wrong and am not feeling energetic enough to
do
the experiment.

And in interest of a complete record in the archives (so that anyone
reading
my post will know about the uncertainty and your proposed correction),
I'm
sending this back to the list.

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