LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-27-2011, 05:27 AM   #1
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Rep: Reputation: 18
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.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-27-2011, 07:03 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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.
 
2 members found this post helpful.
Old 06-27-2011, 08:58 AM   #3
vijay_a258
LQ Newbie
 
Registered: Apr 2009
Location: India-Hyderabad
Distribution: rhel, suse, ubuntu
Posts: 2

Rep: Reputation: 1
Command# grep -r "string" /root/*

Use the above command to search for a "string" in all the folders under root directory
 
1 members found this post helpful.
Old 06-27-2011, 01:28 PM   #4
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Original Poster
Rep: Reputation: 18
Thank you very much both that works..
 
Old 06-27-2011, 01:30 PM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
You're welcome
 
Old 06-27-2011, 03:23 PM   #6
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching for text string in all files ortizmj Linux - Newbie 2 03-03-2011 02:03 PM
Searching a specific directory for files containing a text string lothwen Linux - Newbie 1 11-20-2010 11:58 AM
read files from a folder and grep a string bhagirathi Programming 6 07-06-2009 07:27 AM
Copy files from various locations to a single destination folder deostroll Linux - Newbie 5 05-13-2009 07:52 AM
searching for a string of charcters in some files hhegab Programming 2 04-16-2005 06:07 PM


All times are GMT -5. The time now is 08:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration