LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-26-2002, 11:41 AM   #1
realos
Member
 
Registered: Jul 2002
Location: Germany
Distribution: Redhat 7.3, Debian 3.1, Knoppix 3.1, Ubuntu 6.10
Posts: 113

Rep: Reputation: 15
recursive search of a string in a directory ?!


hello,

I would like to search for a string in all the files situated in two different directories. What is the best way to do so?

it works fine for one file with "less file | grep string" but I don`t know how to produce output of less recursively. Is there some other way to do the job?

thanks in anticipation people,

Last edited by realos; 10-19-2005 at 08:20 AM.
 
Old 11-26-2002, 12:54 PM   #2
Bert
Senior Member
 
Registered: Jul 2001
Location: 406292E 290755N
Distribution: GNU/Linux Slackware 8.1, Redhat 8.0, LFS 4.0
Posts: 1,004

Rep: Reputation: 46
You've tripped into the trap of thinking the less command needs to do something recursively! It's grep that needs to do this recursively, surely:

grep -re string > outfile.txt

-e is for a regular expression. -r is recursively. If you want to do this for HTML tags, have a look at regexlib on google. I've seen some tools in Perl for this purpose. Even wrote one myself once!

Bert
 
Old 11-26-2002, 03:51 PM   #3
realos
Member
 
Registered: Jul 2002
Location: Germany
Distribution: Redhat 7.3, Debian 3.1, Knoppix 3.1, Ubuntu 6.10
Posts: 113

Original Poster
Rep: Reputation: 15
you are right

thanks Bert,

it works. I just stuck because I thought "less " had to provide input for grep recursively.

this forum is great :-)

regards,

Realos
 
Old 11-26-2002, 05:35 PM   #4
Bert
Senior Member
 
Registered: Jul 2001
Location: 406292E 290755N
Distribution: GNU/Linux Slackware 8.1, Redhat 8.0, LFS 4.0
Posts: 1,004

Rep: Reputation: 46
You're welcome.
Wenn ich die Wahl haette, wuerde ich immer Linux fuer dieser Art Probleme benutzen, weil man kann dass nicht mit Windows machen. Man hat Perl mit Linux oder wass - VisualStudio.NET ? Dass ist ein(en?) Witz!!

That was a private joke as my German is rusty.

Last edited by Bert; 11-26-2002 at 05:53 PM.
 
Old 11-27-2002, 04:49 AM   #5
realos
Member
 
Registered: Jul 2002
Location: Germany
Distribution: Redhat 7.3, Debian 3.1, Knoppix 3.1, Ubuntu 6.10
Posts: 113

Original Poster
Rep: Reputation: 15
:-) I got yo

> Das ist ein(en?) Witz!!
correct: das ist EIN Witz.

anyhow, stay cool.
 
  


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
search for a string in c alaios Programming 1 07-07-2005 04:50 PM
Recursive search in bash scripting ! zulfilee Linux - Software 3 12-12-2004 10:40 PM
C....Search a string for a string Scrag Programming 4 06-14-2004 04:15 PM
[c++] Search in a string hylke Programming 5 06-14-2004 11:20 AM
Search for a string TheOriginalH Linux - General 5 09-24-2003 10:48 AM


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