I wanted to search for this particular string $string['site:config']
in my folder. But when I use a normal grep function grep -r "$string['site:config']"
it gives me random results.
The problem with your pattern is that characters like $ [ ]
are characters used to define regular expressions and you have either to escape them:
grep "\$string\['site:config'\]"
or instruct grep to look for the given string as is:
grep -F "$string['site:config']"
without attempting to interpret it as a regular expression.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.