How to find out if a directory in HDFS is empty or not?
February 9, 2022How to copy an index and its contents to a new index in Elasticsearch?
February 23, 2022You 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