I am using GNU grep on Windows 7 command prompt.
I have a file jsutfstr.txt whose content is like this:
some lines
HELLO("abc",adf)
HELLO("def", sd)
some lines
some lines
some lines
And I want to grep the HELLO(..) pattern. In the windows command prompt I used these:
C:\bin>Egrep HELLO\(\"[^)]+\) jsutfstr.txt
HELLO("abc",adf)
HELLO("def", sd)
C:\bin>Egrep HELLO\([^)]+\) jsutfstr.txt
So, the second pattern yields nothing. I don’t understand why I have to specify \” explicitly. Isn’t that the [^)] matches everything not equal to ) including a double quote?
The problem is that you run in to the shell parsing the line first and
^is the escape character forcmd. So the line that gets passed togrepin the second case iswhile in the first case the
"starts a quoted argument wherecmdwill not look into.You can just quote the complete argument to avoid that: