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/
      |\      _,,,---,,_                [EMAIL PROTECTED]
ZZZzz /,`.-'`'    -.  ;-;;,_            [EMAIL PROTECTED]
     |,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/

Reply via email to