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.
dw@circe:~$ set -x dw@circe:~$ grep '^abc.*$\?' testfile + grep '^abc.*$\?' testfile abc;klj? abcasdf dw@circe:~$ grep "^abc.*$\?" testfile + grep '^abc.*$\?' testfile abc;klj? abcasdf dw@circe:~$ grep ^abc.*$\? testfile + grep '^abc.*$?' testfile dw@circe:~$ grep ^abc.*\?$ testfile + grep '^abc.*?$' testfile abc;klj? dw@circe:~$ grep '^abc.*\?$' testfile + grep '^abc.*\?$' testfile abc;klj? abcasdf dw@circe:~$ grep "^abc.*\?$" testfile + grep '^abc.*\?$' testfile abc;klj? abcasdf dw@circe:~$ On Sat, Mar 24, 2012 at 2:05 PM, Mike Frysinger <[email protected]> wrote: > On Friday 23 March 2012 20:52:49 Dan wrote: > > dw@circe:~$ grep '^abc.*$\?' testfile > > abc;klj? > > abcasdf > > dw@circe:~$ grep "^abc.*$\?" testfile > > abc;klj? > > abcasdf > > dw@circe:~$ grep ^abc.*$\? testfile > > dw@circe:~$ > > 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 ~~
