LinuxQuestions.org
Help answer threads with 0 replies.
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 12-17-2006, 06:34 PM   #1
sancho1980
Member
 
Registered: May 2006
Location: Leipzig, Germany
Distribution: Kanotix 64
Posts: 45

Rep: Reputation: 15
find pattern in any file in directory


hi

i know the grep command, which searches for patterns in files
i also tried "grep pattern *", which searches for a pattern in any file in the current directory
but how can i search for a patterin in *any* file within the current directory OR within any subdirectory of the current directory OR within any subdirectory of any subdirectory of the current directory OR...you know what i mean, recursively...
thanx for your hints!
martin

Last edited by sancho1980; 12-17-2006 at 06:35 PM.
 
Old 12-17-2006, 06:44 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
find . -exec grep 'YourRegexOrPattern' {} \;

--- rod.
 
Old 12-17-2006, 07:02 PM   #3
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
What version of grep are you using? If it supports the recursive (-r) option:
Code:
grep -r 'SomeString' /path/to/search/*
 
Old 12-19-2006, 08:11 AM   #4
sancho1980
Member
 
Registered: May 2006
Location: Leipzig, Germany
Distribution: Kanotix 64
Posts: 45

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by theNbomr
find . -exec grep 'YourRegexOrPattern' {} \;

--- rod.
Can you please explain this command to me?

especially the {} \; - part ... i have no idea about shell programming... :-(

thanx,

martin
 
Old 12-19-2006, 08:14 AM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 52
man find

its well explained
 
  


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
find | grep <pattern> not working duvalr Linux - Software 4 09-17-2006 04:07 AM
how to find a pattern using shell script sharad Linux - General 1 05-23-2006 03:50 AM
Command to find similar file names in a directory Ottoguy Linux - Newbie 4 02-02-2006 05:42 AM
How to recursively rename files using their directory name pattern ceg4048 Linux - General 2 09-28-2005 01:16 PM
Find string pattern in directory of text files magnum818 Linux - Newbie 2 10-15-2003 08:19 PM


All times are GMT -5. The time now is 04:34 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