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

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
Date: Tue, 5 Apr 2005 16:55:57 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: mitch gart <mgart AT kronos DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: sed and searches for $
In-Reply-To: <loom.20050405T215243-900@post.gmane.org>
Message-ID: <Pine.GSO.4.61.0504051648310.29048@slinky.cs.nyu.edu>
References: <loom DOT 20050405T215243-900 AT post DOT gmane DOT org>
MIME-Version: 1.0

On Tue, 5 Apr 2005, mitch gart wrote:

> 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.
> [snip]
>   sed -n  -e /\\$/= junk
> [snip]
> 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.

It's a bash quoting issue, not a CRLF issue.  Bash recognizes '\' as a
special quote character, so sed only sees *one* backslash when you run
from bash, making it search for a single dollar sign (not what you wanted,
I suspect).  Use single quotes in bash to wrap strings with special
characters.  The following should work from bash:

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

BTW, this is not in any way Cygwin-specific.
HTH,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

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