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.
-
@ylabidi: So, in this case I cannot search for this particular string?xan– xan2013-04-01 04:41:07 +00:00Commented Apr 1, 2013 at 4:41
-
use -F to force grep to interpret the given pattern as a normal string and not as a regex.b2Wc0EKKOvLPn– b2Wc0EKKOvLPn2013-04-01 04:42:12 +00:00Commented Apr 1, 2013 at 4:42
-
The problem with your pattern is that characters like $ [ ] are characters used to define regular expressions and you have either to escape them or instruct grep to look for the given string as is, without attempting to interpret it as a regular expression.b2Wc0EKKOvLPn– b2Wc0EKKOvLPn2013-04-01 04:44:32 +00:00Commented Apr 1, 2013 at 4:44
-
Switch over to TextCrawler instead \o/Paulo Roberto– Paulo Roberto2013-04-01 04:45:30 +00:00Commented Apr 1, 2013 at 4:45
-
1How's that working for you ?b2Wc0EKKOvLPn– b2Wc0EKKOvLPn2013-04-01 04:48:52 +00:00Commented Apr 1, 2013 at 4:48
|
Show 1 more comment
1 Answer
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.