I am grepping some php code files for an array variable and I ran into an issue which I am curious to understand.
I attempted to grep:
grep -RF "$array_variable['some_key'][$key_variable]" *
and it returned nothing. However, if I escape the second dollar sign, it then finds lines with that pattern.
grep -RF "$array_variable['some_key'][\$key_variable]" *
The -F flag from the man page says it treats the pattern as a fixed string and not a regex. It seems to handle the first dollar sign only.
Please help me understand how grep is interpreting this command. Could this be a shell issue rather than a regex issue?
UPDATE Added an additional array layer, which shows why I don't want to use single quotes. It's more work to escape the single quotes than the dollar sign.