Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-22-2011, 12:03 AM   #1
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
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 607

Rep: Reputation: 218Reputation: 218Reputation: 218
What about google ?

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

Rep: Reputation: 185Reputation: 185
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
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
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,077

Rep: Reputation: 400Reputation: 400Reputation: 400Reputation: 400Reputation: 400
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
Registered: Jul 2011
Posts: 38

Original Poster
Rep: Reputation: Disabled
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;
if($_ =~ m/__GNUC__/){
say $myfile;

a simple solution.
0 members found this post helpful.


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:15 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration