bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using $ in quotes with characters after it


From: Dan
Subject: Using $ in quotes with characters after it
Date: Wed, 21 Mar 2012 23:16:43 -0400

Hello,

I've noticed something strange when using grep.  It has to do with a
pattern similar to this one: "hello$world".  It seems to me that the
command executes fine, but the output does not seem to be in any way
predictable.  Of course the $ token signals the end of a line, so this
doesn't really make sense as a regular expression, but why does grep output
anything at all?  It should really throw an error when receiving
expressions like that one.  One other thing, having the pattern in quotes
matters.  If you don't quote it then grep outputs nothing, which is still
not what I would expect but at least the malformed regexp isn't throwing
false matches.  If there's a reason for this behavior could somebody please
enlighten me on why and what the logic is when dealing with the bad pattern?

Thanks,
Daniel Wilson
-- 
~~ Whatever happens, the sun's still gonna come up tomorrow ~~


reply via email to

[Prev in Thread] Current Thread [Next in Thread]