How to match strings that contain $ character?Example - by the following grep doesn't return the match.  param=ambari_parameter$  echo ambari_parameter$ | grep $param  echo ambari_parameter$ | grep $param
How to match a string containing the character $ with grep?
bash;grep;special characters
In this case, the string in $param will be interpreted as a regular expression.  This expression contains a $ which anchors the ambari_parameter in the pattern to the end of the match.  Since ambari_parameter$ in the input data does not contain ambari_parameter at the very end, it won't match.You may choose to match with a fixed string  instead of a regular expression, by using -F:echo ambari_parameter$ | grep -F -e $paramI also used -e here to force grep to recognize the following argument as a pattern. This is necessary if $param starts with a dash (-).To further require that the whole input line matches the complete string, add -x:echo ambari_parameter$ | grep -xF -e $paramIf $param is ambari_parameter$, then this will not match the string _ambari_parameter$ (which will match if -x is left out).