Linux : Search for a particular word in all the files

I am using Ubuntu 12 . I am trying to search for the word "SymbolSetThree" in my Ubuntu Machine home directory .

For this i used

 grep "SymbolSetThree" /home

It simply displayed as grep: /home: Is a directory

Please let me know how to search for a particular word in all the files in Linux ??

This is what i tried

sai@sai-Aspire-4720Z:/$  grep "SymbolSetThree" /home
grep: /home: Is a directory

You are close, you just need the -r switch to have your command working properly.

 grep -r "SymbolSetThree" /home

will do the trick.


Use `find:

find /home -type f | xargs grep SymbolSetThree

The same result can be achieved by using the -exec argument to find (instead of xargs ).


对于这种类型的任务,我真的很喜欢ack-grep,它是面向程序员的(只有源文件,.py .rb .c .sh),但使用-a它会查找所有类型的文件。

ack-grep -a "SymbolSetThree"
链接地址: http://www.djcxy.com/p/78020.html

上一篇: Python:导入与函数名称相同的模块

下一篇: Linux:搜索所有文件中的特定单词