[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using $ in quotes with characters after it
From: |
Dan |
Subject: |
Re: Using $ in quotes with characters after it |
Date: |
Sat, 24 Mar 2012 15:06:00 -0400 |
This is the output after running `set -x`. It looks like the shell is
behaving properly. It's un-escaping the question mark when it's supposed
to be and it isn't when it isn't supposed to be. Grep shouldn't be
producing that output though. The only explanation I can think of is that
the wildcard is being too greedy and consuming all of the string. But from
what I know that's not how it works.
address@hidden:~$ set -x
address@hidden:~$ grep '^abc.*$\?' testfile
+ grep '^abc.*$\?' testfile
abc;klj?
abcasdf
address@hidden:~$ grep "^abc.*$\?" testfile
+ grep '^abc.*$\?' testfile
abc;klj?
abcasdf
address@hidden:~$ grep ^abc.*$\? testfile
+ grep '^abc.*$?' testfile
address@hidden:~$ grep ^abc.*\?$ testfile
+ grep '^abc.*?$' testfile
abc;klj?
address@hidden:~$ grep '^abc.*\?$' testfile
+ grep '^abc.*\?$' testfile
abc;klj?
abcasdf
address@hidden:~$ grep "^abc.*\?$" testfile
+ grep '^abc.*\?$' testfile
abc;klj?
abcasdf
address@hidden:~$
On Sat, Mar 24, 2012 at 2:05 PM, Mike Frysinger <address@hidden> wrote:
> On Friday 23 March 2012 20:52:49 Dan wrote:
> > address@hidden:~$ grep '^abc.*$\?' testfile
> > abc;klj?
> > abcasdf
> > address@hidden:~$ grep "^abc.*$\?" testfile
> > abc;klj?
> > abcasdf
> > address@hidden:~$ grep ^abc.*$\? testfile
> > address@hidden:~$
>
> run `set -x` before these commands to see what exactly is being passed to
> grep. the quoting/expansion rules of the shell are probably changing what
> grep is actually seeing.
> -mike
>
--
~~ Whatever happens, the sun's still gonna come up tomorrow ~~