How to view the contents of a GZiped file in HDFS? - Big Data In Real World

How to view the contents of a GZiped file in HDFS?

How to find out if a directory in HDFS is empty or not?
February 9, 2022
How to copy an index and its contents to a new index in Elasticsearch?
February 23, 2022
How to find out if a directory in HDFS is empty or not?
February 9, 2022
How to copy an index and its contents to a new index in Elasticsearch?
February 23, 2022

You can not directly view or preview the content of a GZip file in HDFS. HDFS does not provide a direct command to do that.

Solution

Zcat is a command line utility for viewing the contents of a compressed file without literally uncompressing it. It expands a compressed file to standard output allowing you to have a look at its contents. In addition, zcat is identical to running gunzip -c command.

Pipe the output of hdfs dfs -cat on the file to zcat followed by a head to see the first few line.

hdfs dfs -cat /user/hirw/part-00000.gz | zcat | head -n 20
Big Data In Real World
Big Data In Real World
We are a group of Big Data engineers who are passionate about Big Data and related Big Data technologies. We have designed, developed, deployed and maintained Big Data applications ranging from batch to real time streaming big data platforms. We have seen a wide range of real world big data problems, implemented some innovative and complex (or simple, depending on how you look at it) solutions.

Comments are closed.

How to view the contents of a GZiped file in HDFS?
This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy.

Hadoop In Real World is now Big Data In Real World!

X