I thought I found the perfect answer with How do I find all files containing specific text on Linux? , so I tried it:
[Michael@devserver ~]$ grep -rnw '/var/www/concrete5.7.5.9/' -e "Concrete\Core\Block\BlockController"
[Michael@devserver ~]$
None show, but I know there should have been a match.
[Michael@devserver ~]$ grep -rnw '/var/www/concrete5.7.5.9/concrete/blocks/html' -e "BlockController"
/var/www/concrete5.7.5.9/concrete/blocks/html/controller.php:5:use \Concrete\Core\Block\BlockController;
/var/www/concrete5.7.5.9/concrete/blocks/html/controller.php:7:class Controller extends BlockController
[Michael@devserver ~]$
I also tried escaping the backslash to no avail.
[Michael@devserver ~]$ grep -rnw '/var/www/concrete5.7.5.9/' -e "Concrete\\Core\\Block\\BlockController"
[Michael@devserver ~]$
Also tried single quotes to no avail.
[Michael@devserver ~]$ grep -rnw '/var/www/concrete5.7.5.9/' -e 'Concrete\Core\Block\BlockController'
[Michael@devserver ~]$
How to find all files containing specific text which includes a backslash on Linux?
使用单引号和转义反斜杠。
grep -rnw '/var/www/concrete5.7.5.9/' -e'Concrete\\Core\\Block\\BlockController'
使用单引号。
grep -rnw '/var/www/concrete5.7.5.9/' -e 'Concrete\Core\Block\BlockController'
Grep has an option -F
to interpret the pattern literally and not as a regular expression. For example:
$ cat infile
use \Concrete\Core\Block\BlockController;
class Controller extends BlockController
$ grep 'Concrete\Core\Block\BlockController' infile # No match!
$ grep -F 'Concrete\Core\Block\BlockController' infile # Matches!
use \Concrete\Core\Block\BlockController;
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.