Hi all,

On Sat, 03 Sep 2011 17:15:51 -0400
Shawn H Corey <shawnhco...@gmail.com> wrote:

> On 11-09-03 05:01 PM, Jon Forsyth wrote:
> > Hello,
> >
> > According to the grep manual page I can use the -P option to use Perl
> > regular expressions as follows:
> >
> > grep -P PERL_REGEX  INPUT_FILE
> >
> > however, I cannot get the following pattern to match a literal dollar sign:
> >
> > grep -P makan\$  file.txt
> 
> # You have to get the backslash past the shell
> 
> grep -P 'makan\$' file.txt
> 
> # or
> 
> grep -P makan\\$ file.txt
> 

Just to be a bit more pedantic, in this case:

grep -P makan\\\$ file.txt 

would be safer and more idiomatic, because otherwise the shell would treat the
string as a literal backslash followed by the opening of a shell variable,
which all start with "$".

Regards,

        Shlomi Fish


-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Best Introductory Programming Language - http://shlom.in/intro-lang

I might be mad. But I’m a mad genius.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to