LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 10: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, 01:35 AM   #2
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Stretch
Posts: 612

Rep: Reputation: 125Reputation: 125
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, 02: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, 04:04 AM   #4
divyashree
Senior Member
 
Registered: Apr 2007
Location: Bangalore, India
Distribution: RHEL,SuSE,CentOS,Fedora,Ubuntu
Posts: 1,386

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

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

All times are GMT -5. The time now is 04:06 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
Open Source Consulting | Domain Registration