LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how can I find all the files in different folds which contains a word? (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-find-all-the-files-in-different-folds-which-contains-a-word-898696/)

mei0fei 08-22-2011 12:03 AM

how can I find all the files in different folds which contains a word?
 
what can I do?

NoStressHQ 08-22-2011 12:07 AM

What about google ?

This time I did it for you... (check this)

rob.rice 08-22-2011 01:41 AM

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

mei0fei 08-22-2011 05:06 AM

I am just using PERL File::Util to get out all files and directories .

i92guboj 08-22-2011 05:24 AM

grep -R

Andrew Benton 08-22-2011 06:08 AM

grep -rl "text-to-search-for" /path/to/files

mei0fei 08-22-2011 07:02 AM

#!/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.


All times are GMT -5. The time now is 10:50 PM.