LinuxQuestions.org
Review your favorite Linux distribution.
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 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,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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,141

Rep: Reputation: 168Reputation: 168
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: 57
man find

its well explained
 
  


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

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

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