LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-07-2007, 10:45 PM   #1
muby
LQ Newbie
 
Registered: Oct 2007
Posts: 28

Rep: Reputation: 15
searching text within a folder in linux


i just wonder if this is possible (searching text within a folder in linux), i doing programming i need to know in which file certain funtions are, any one?

thank you
Muby
 
Old 10-07-2007, 10:52 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
find /path/to/folder -type f | grep 'text string'

This should recursively search through the files in folder for the given text string.

Last edited by bigrigdriver; 10-07-2007 at 10:55 PM.
 
Old 10-08-2007, 12:13 AM   #3
speck
Member
 
Registered: Nov 2001
Location: US
Distribution: Slackware 14.2
Posts: 375

Rep: Reputation: 115Reputation: 115
If you just need to search only a single directory (and no subdirectories):
Code:
grep "string to search" *
If you need to search multiple directories and/or subdirectories:
Code:
find /dir/to/search_1 /dir/to/search_2 -type f -print | xargs  grep "string to search"
 
Old 10-08-2007, 01:13 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
or use grep -r
 
Old 10-08-2007, 07:45 AM   #5
muby
LQ Newbie
 
Registered: Oct 2007
Posts: 28

Original Poster
Rep: Reputation: 15
bigrigdriver, speck & chrism01 thank you very much
 
  


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
searching for Text within files. waelaltaqi Linux - Software 2 06-18-2007 02:56 PM
LQ searching with text browsers dive LQ Suggestions & Feedback 1 12-31-2006 11:16 AM
Searching for text within pdfs - possible? will103 Linux - Software 6 12-05-2005 09:41 AM
text searching sopiaz57 Linux - Software 4 06-02-2005 01:00 PM
Searching a text file - complicated cyph3r7 Linux - General 2 12-16-2003 10:45 AM

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

All times are GMT -5. The time now is 03:05 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
Open Source Consulting | Domain Registration