LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training 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 08-22-2011, 12:03 AM   #1
mei0fei
Member
 
Registered: Jul 2011
Posts: 38

Rep: Reputation: Disabled
how can I find all the files in different folds which contains a word?


what can I do?
 
Old 08-22-2011, 12:07 AM   #2
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 569

Rep: Reputation: 191Reputation: 191
What about google ?

This time I did it for you... (check this)
 
Old 08-22-2011, 01:41 AM   #3
rob.rice
Senior Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 1,006

Rep: Reputation: 168Reputation: 168
midnight commander AKA "mc" will also do it for you
command > find file
mc is a CLI program so you have to run it from a some kind of terminal
 
Old 08-22-2011, 05:06 AM   #4
mei0fei
Member
 
Registered: Jul 2011
Posts: 38

Original Poster
Rep: Reputation: Disabled
I am just using PERL File::Util to get out all files and directories .
 
0 members found this post helpful.
Old 08-22-2011, 05:24 AM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 386Reputation: 386Reputation: 386Reputation: 386
grep -R
 
Old 08-22-2011, 06:08 AM   #6
Andrew Benton
Senior Member
 
Registered: Aug 2003
Location: Birkenhead/Britain
Distribution: Linux From Scratch
Posts: 2,073

Rep: Reputation: 64
grep -rl "text-to-search-for" /path/to/files
 
Old 08-22-2011, 07:02 AM   #7
mei0fei
Member
 
Registered: Jul 2011
Posts: 38

Original Poster
Rep: Reputation: Disabled
#!/usr/bin/perl
use feature ':5.10';
use warnings;
use strict;

use File::Util;

my($f) = File::Util->new();
my(@dirs_and_files) = $f->list_dir('/home/mei/Downloads/core.samples.v0.1b6/effo','--recurse');

foreach(@dirs_and_files) {
my($myfile) = $_;
open(my $fh, '<', $myfile) or continue;
while(<$fh>){
chomp;
if($_ =~ m/__GNUC__/){
say $myfile;
last;
}
}
}

a simple solution.
 
0 members found this post helpful.
  


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
How can i read two files word by word at a time using any loop by shell script? vaibhavs17 Programming 16 03-19-2010 03:48 AM
word by word comparison in two files using loop in shell script vaibhavs17 Programming 2 03-05-2010 07:41 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
[SOLVED] find a word in a file, and change a word beneath it ?? vikas027 Programming 10 02-14-2008 09:46 PM
find a word within any files Linh Linux - General 6 06-06-2004 11:15 AM

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

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