delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/04/05/16:24:27

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
To: cygwin AT cygwin DOT com
From: mitch gart <mgart AT kronos DOT com>
Subject: sed and searches for $
Date: Tue, 5 Apr 2005 20:02:02 +0000 (UTC)
Lines: 23
Message-ID: <loom.20050405T215243-900@post.gmane.org>
Mime-Version: 1.0
X-Complaints-To: usenet AT sea DOT gmane DOT org
X-Gmane-NNTP-Posting-Host: main.gmane.org
User-Agent: Loom/3.14 (http://gmane.org/)
X-Loom-IP: 158.228.56.15 (Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2)
X-IsSubscribed: yes

It seems like sed works differently when searching for end-of-line ($)
depending if it's launched from a DOS prompt or from inside a shell
prompt.  For example if I have a file named junk which contains 1 line

  hello\

( \ is the last character of the line.)  The command

  sed -n  -e /\\$/= junk

prints

  1

when launched from DOS, and prints nothing when launched from the shell.

I've been pretty mystefied by this but I'm guessing the reason has something
to do with the difference between lines terminated by \r\n (DOS) and \n
(Unix).

Anyway what I want is to write a sed script that recognizes both kinds
of line separators, and runs correctly from inside the shell.  Can somebody 
tell me how?   Thanks.


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