I am trying to find all the files has text: $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']
, I tried to use grep -rl '$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']' .
, but later on found []
has special meaning as search pattern. So what is the right command for searching text $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']
?
If you include special characters in patterns typed on the command line, escape them by enclosing them in single quotation marks to prevent inadvertent misinterpretation by the shell or command interpreter. To match a character that is special to grep –E, put a backslash ( \ ) in front of the character.
Whenever you use a grep regular expression at the command prompt, surround it with quotes, or escape metacharacters (such as & ! . * $ ? and \ ) with a backslash ( \ ). finds any line in the file list starting with "b." displays any line in list where "b" is the only character on the line.
The wildcard * (asterisk) can be a substitute for any number of letters, numbers, or characters. Note that the asterisk (*) works differently in grep. In grep the asterisk only matches multiples of the preceding character. The wildcard * can be a substitute for any number of letters, numbers, or characters.
Grep can identify the text lines in it and decide further to apply different actions which include recursive function or inverse the search and display the line number as output etc. Special characters are the regular expressions used in commands to perform several actions like #, %, *, &, $, @, etc.
You are right that [
and ]
are special characters. Quote them with \
or use fgrep
instead. The latter is plain string search:
fgrep "\$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']" ...
You still need to quote $
though because it is otherwise interpreted by bash
and other shells.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With