I'm running the following command:
cat something | egrep "(abc|def)$"
On a server running Linux.
The same OS with kernel 2.6.18 gives the correct answer, while with 2.6.19 I get:
Illegal variable name.
Apparently the $ sign is causing the error, but the question is why is it behaving differently across kernels?
1) Are you using the same type of shell on both machines?
2) Have you tried using single quotes, so that the shell doesn't try to interpret the dollar sign as a variable?
Its more likely this is an issue with the shell you're running. First, the quotes; when using single quotes, variables won't be replaced in the outcoming string. I.e.,
In your case, its literally trying to execute
$
, but$
is not a valid variable name. If you use single quotes, the shell won't allow the dollar sign to be replaced.