LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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: 73

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: 73

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
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,471

Rep: Reputation: 1888Reputation: 1888Reputation: 1888Reputation: 1888Reputation: 1888Reputation: 1888Reputation: 1888Reputation: 1888Reputation: 1888Reputation: 1888Reputation: 1888
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: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,533
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
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


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


All times are GMT -5. The time now is 07:37 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration