Grep across multiple files in Hadoop

0 votes

I need to find which of ~100 files in my Hadoop filesystem contain a certain string.

I can see the files I wish to search like this:

bash-3.00$ hadoop fs -ls /apps/edureka/community/real-time

..which returns several entries like this:

-rw-r--r--   3 community edureka 1073741824 2019-07-01 22:50 /apps/edureka/community/HADOOP_consolidated_RT_v1x0_20120716_aa
-rw-r--r--   3 community edureka 1073741824 2019-07-01 22:50 /apps/edureka/community/HADOOP_consolidated_RT_v1x0_20120716_ab
Jan 8, 2019 by Neha
• 6,300 points
4,791 views

1 answer to this question.

0 votes

You are looking to applying to grep command on hdfs folder

hdfs dfs -cat /user/coupons/input/201807160000/* | grep -c null

here cat recursively goes through all files in the folder and I have applied grep to find count.

answered Jan 8, 2019 by Frankie
• 9,830 points
But it doesn't print the name of the file where it found the string.. so most of the times not useful..

is it possible to print the file name?

Hi,

Yes, you can't list down the file names using the cat command. This command is used to read the data from a file. You can use the ls command instead of the cat command.

$ hdfs dfs -ls /path

Related Questions

+1 vote
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 11,380 points
11,220 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 11,380 points
2,707 views
+2 votes
11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
110,030 views
–1 vote
1 answer

Hadoop dfs -ls command?

In your case there is no difference ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by kurt_cobain
• 9,350 points
4,720 views
0 votes
1 answer

How does Hadoop process data which is split across multiple boundaries in an HDFS?

I found some comments: from the Hadoop ...READ MORE

answered Jul 1, 2019 in Big Data Hadoop by ravikiran
• 4,620 points
1,039 views
0 votes
1 answer

How to sync Hadoop configuration files to multiple nodes?

Dear Raman, Hope you are doing great. Please accept ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,570 points
1,088 views
0 votes
1 answer

How to sync Hadoop configuration files to multiple nodes?

For syncing Hadoop configuration files, you have ...READ MORE

answered Jun 21, 2018 in Big Data Hadoop by HackTheCode
1,426 views
+3 votes
5 answers

How to read multiple data files in python

Firstly we will import pandas to read ...READ MORE

answered Apr 6, 2018 in Python by DeepCoder786
• 1,720 points
15,467 views
0 votes
1 answer

What are SUCCESS and part-r-00000 files in Hadoop?

Yes, both the files i.e. SUCCESS and ...READ MORE

answered Apr 12, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
12,799 views
0 votes
1 answer

Files for Configuring HDFS in Hadoop 2.2.0?

By default these Hadoop configuration files are ...READ MORE

answered Apr 15, 2018 in Big Data Hadoop by Shubham
• 13,490 points
872 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP