LinuxQuestions.org
Review your favorite Linux distribution.
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 07-27-2012, 09:17 PM   #1
raihan26
LQ Newbie
 
Registered: Jul 2012
Posts: 1

Rep: Reputation: Disabled
Find a String in Multiple Files


I am new to Unix/Linux world, I am working with Hadoop. And I need to find a String in more than 100 files. And also which files contains that particular String. So below is my scenario-

So I go to Bash Prompt, and then I type like below to get all the files under a folder and it is like around 100 files under real-time folder.

Code:
bash-3.00$ hadoop fs -ls /apps/hdmi-technology/b_apdpds/real-time
So I am showing only two files that I will be getting from the above command but we have more than 2 and it is around 100 files.

Code:
-rw-r--r--   3 b_apdpds hdmi-technology 1073741824 2012-07-18 22:50 /apps/hdmi-technology/b_apdpds/real-time/HADOOP_REALTIME_consolidated_RT_v1x0_20120716_aa
-rw-r--r--   3 b_apdpds hdmi-technology 1073741824 2012-07-18 22:50 /apps/hdmi-technology/b_apdpds/real-time/HADOOP_REALTIME_consolidated_RT_v1x0_20120716_ab
And I need to find a String named
Code:
bcd4bc3e1380a56108f486a4fffbc8dc
in all of the 100 files and also which files contain that particular String. Is this possible to do it?
 
Old 07-28-2012, 12:35 AM   #2
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Jessie
Posts: 592

Rep: Reputation: 119Reputation: 119
Could it be that the other 98 files are hidden files? Try ls with the -a option to show hidden files also.

To search files for a particular string, you can use the grep command.
Code:
grep "bcd4bc3e1380a56108f486a4fffbc8dc" /apps/hdmi-technology/b_apdpds/real-time/*
See the manpages for additional info on grep.
Code:
man grep
Hope this helps.
 
Old 07-28-2012, 01:39 AM   #3
eyanu
Member
 
Registered: Jul 2012
Location: kampala,Uganda
Distribution: backtrack
Posts: 87

Rep: Reputation: Disabled
grep -R "bcd4bc3e1380a56108f486a4fffbc8dc" /path/to/folder/*
 
Old 07-28-2012, 03:04 AM   #4
divyashree
Senior Member
 
Registered: Apr 2007
Location: bbsr,orissa,India
Distribution: RHEL5 ,RHEL4,CENT OS5,FEDORA,UBUNTU
Posts: 1,363

Rep: Reputation: 135Reputation: 135
Hi Raihan, Welcome to LQ.

You can use find :

Code:
find "/apps/hdmi-technology/b_apdpds/real-time" -type f -exec grep -il "bcd4bc3e1380a56108f486a4fffbc8dc" {} \;

Last edited by divyashree; 07-28-2012 at 03:06 AM.
 
  


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
[SOLVED] How to find files that contain one string, but don't contain another. PatrickDickey Linux - Newbie 2 09-11-2011 06:00 AM
[SOLVED] Need to remove dynamic string across multiple lines and files. vandigroup Linux - Server 2 05-14-2011 11:50 PM
How to find multiple strings into multiple files ? moicpit Linux - General 10 04-25-2010 11:19 AM
Find & Replace string in multiple files Rudy Linux - General 14 04-15-2010 08:10 AM
How to find those files having specific string??? saeed Red Hat 4 07-19-2006 11:50 AM

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

All times are GMT -5. The time now is 07:40 PM.

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