I have the following grep query
$ grep -nr "ActiveChild\s*=" .
This finds all instances of ActiveChild followed by whitespace-
ActiveChild = "ABC"
ActiveChild = "PQR"
ActiveChild = "XYZ"
However, it also gives me results like
If ActiveChild = "LMN" Then
I want to avoid the above case. I want to ensure that “ActiveChild” is the first word that appears on the line that I am searching. It doesn’t matter if there is whitespace before it. Unfortunately, writing something like
grep -nr "\s*ActiveChild\s*=" .
doesn’t help at all. How can I write such a query? Also, is “query” the right word, or is something else used in the context of grep?
1 Answer