rnw": search for a string in all files

Related question: How do I find all files containing specific text on Linux?

I have been using the command mentioned in the answer of above question to search for string occurences in all files:

grep -rnw '/path/to/somewhere/' -e "pattern"

However lately I encountered a problem, shown in the following picture: 在这里输入图像描述

Looks like this command only recognizes strings that stand out as a word or something. How should I modify the command to improve my search result?


explainshell helpfully explains your command, and gives an excerpt from man grep :

   -w, --word-regexp
          Select  only  those  lines  containing matches that form whole words. 

So just remove -w since that explicitly does what you don't want:

grep -rn '/path/to/somewhere/' -e "pattern"
链接地址: http://www.djcxy.com/p/13674.html

上一篇: 包含命令在OSX Zsh中不起作用

下一篇: rnw“:在所有文件中搜索一个字符串