This is the mail archive of the
mailing list for the Cygwin project.
Re: sed and searches for $
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: mitch gart <mgart at kronos dot com>
- Cc: cygwin at cygwin dot com
- Date: Tue, 5 Apr 2005 16:55:57 -0400 (EDT)
- Subject: Re: sed and searches for $
- References: <loom.20050405T215243email@example.com>
- Reply-to: cygwin at cygwin dot com
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
> sed -n -e /\\$/= junk
> 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.
|\ _,,,---,,_ firstname.lastname@example.org
ZZZzz /,`.-'`' -. ;-;;,_ email@example.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