I am grepping through some VB source files. I use the following query -      grep -nr GlobalCommArea\s*=\s*.*\.Transaction . Some of the lines, however, are commented and begin with a single line comment. A single line comment in VB starts with a single quote - ' Unfortunately, I cannot simply remove all those lines that have a single quote in them, because some of the lines have a single quote comment after the line of code. So I tried something like this to remove the single quote at the start of the line      grep -nr GlobalCommArea\s*=\s*.*\.Transaction . | grep -v ^\s*'However, this did not work. How to do this?
How to grep for a single quote?
grep
You are using grep -n which prefixes matches with line numbers, so your second pattern ^\s*' will never match.  Instead, you can use one single regex:grep -nr ^[^']*GlobalCommArea\s*=\s*.*\.Transaction .This searches for instances of your pattern not preceded by any single quotes.