LinuxQuestions.org
Latest LQ Deal: Linux Power User 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 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,889

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
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: 354

Rep: Reputation: 93
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: Centos 6.9, Centos 7.3
Posts: 17,374

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


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 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 05:27 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration