Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux : Search for a particular word in all the files

Tags:

linux

grep

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
like image 718
Pawan Avatar asked Jan 21 '13 18:01

Pawan


2 Answers

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).

like image 31
NPE Avatar answered Sep 28 '22 03:09

NPE


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

 grep -r "SymbolSetThree" /home

will do the trick.

like image 53
Gilles Quenot Avatar answered Sep 28 '22 02:09

Gilles Quenot