LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   searching a particular string in all files of a single folder (https://www.linuxquestions.org/questions/linux-newbie-8/searching-a-particular-string-in-all-files-of-a-single-folder-888542/)

dinakumar12 06-27-2011 04:27 AM

searching a particular string in all files of a single folder
 
Hi all,

I just want to know if we can search for a particular string in all files of a particular folder in linux.

if a folder has 100files only that hundred files needs to be checked for a particular string.

if its there,kindly post your suggestions.

Thanks&regards,
Dinesh.

druuna 06-27-2011 06:03 AM

Hi,

Yes, you can do that in 2 easy steps.
Code:

cd /to/the/specific/folder
grep "string" *

Also have a look at the grep manual page (man grep), it has a lot of useful options.

Hope this helps.

vijay_a258 06-27-2011 07:58 AM

Command# grep -r "string" /root/*

Use the above command to search for a "string" in all the folders under root directory

dinakumar12 06-27-2011 12:28 PM

Thank you very much both that works..

druuna 06-27-2011 12:30 PM

You're welcome :)

lithos 06-27-2011 02:23 PM

Just a reminder, that grep is CaSE sENSitiVe, so in order to make it not sensitive use option "-i".


All times are GMT -5. The time now is 02:30 AM.