LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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-07-2010, 04:25 AM   #1
siranjeevi
Member
 
Registered: May 2010
Location: India
Posts: 79

Rep: Reputation: 7
command to find a specific word in directories and subdirectories?


Hi,
Can anyone please tell me the command used to find a specific word in directories and sub-directories in linux?

I searched in net as well as in this forum but i couldn't find.

Thanks in advance.
 
Old 06-07-2010, 04:35 AM   #2
sica07
Member
 
Registered: May 2008
Distribution: Arch
Posts: 47
Blog Entries: 3

Rep: Reputation: 16
Do you mean a specific word in the directory name or a specific word in the content of the directory (files). For the first case use:
Code:
find /directory -name foo
For the second case, try:
Code:
grep -R "foo" /directory
 
Old 06-09-2010, 07:20 AM   #3
siranjeevi
Member
 
Registered: May 2010
Location: India
Posts: 79

Original Poster
Rep: Reputation: 7
Quote:
Originally Posted by sica07 View Post
Do you mean a specific word in the directory name or a specific word in the content of the directory (files). For the first case use:
Code:
find /directory -name foo
For the second case, try:
Code:
grep -R "foo" /directory
Thanks for your response i asked about specific word in the contents of the file thanks alot,
 
Old 06-09-2010, 08:35 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Please mark as SOLVED once you have a solution.
 
Old 06-09-2010, 09:19 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by siranjeevi View Post
Thanks for your response i asked about specific word in the contents of the file thanks alot,
That's going to depend on the format of the files; for plain text, find can run grep on each file but for .pdf, .odt ...
 
  


Reply



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
using find to only search specific directories isaaclw Linux - Software 5 01-09-2010 08:01 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
FIND: Only directories which contain specific files brian.m Linux - General 2 05-07-2009 09:25 PM
Command "find" misses some subdirectories vallond Linux - Enterprise 0 07-19-2007 04:55 AM
Find files, directories that are own by specific user mikeshn Linux - General 2 02-12-2004 03:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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
Open Source Consulting | Domain Registration