On Sun, 2003-02-09 at 23:09, Cedric Veilleux wrote: > Hi, > > What is the correct regular expression for a simple $ character? I want to > filter a file for any lines containing a $ char, but it does not work.. > > man grep tells me $ is a special regular expression char.. I try to escape it > using \$ but it doesn't work.. > > grep $ someFile > > grep \$ someFile > > grep "\$" someFile > > grep /$ someFile > > nothing gives me the result expected!
As far as I can tell, you will need to use grep's -E switch to invoke extended regex support (how you probably expected it to behave). You can also use egrep, which is pretty much identical to 'grep -E'. Try: # Single quotes to use pattern as is grep -E '\$' myfile egrep '\$' myfile or # Double quotes, but you need to use a double slash to escape the slash # for bash's benefit. grep -E "\\$" myfile egrep "\\$" myfile -- Jimmie Fulton <[EMAIL PROTECTED]> -- [EMAIL PROTECTED] mailing list
