4. Looking Up Files in Hadoop Archives

The hdfs dfs -ls command can be used to look up files in Hadoop archives. Using the example /user/zoo/foo.har archive created in the previous section, use the following command to list the files in the archive:

hdfs dfs -ls har:///user/zoo/foo.har/

This command returns:


These archives were created with the following command:

hadoop archive -archiveName foo.har -p /user/hadoop dir1 dir2 /user/zoo

If you change the command to:

hadoop archive -archiveName foo.har -p /user/ hadoop/dir1 hadoop/dir2 /user/zoo

And then run the following command:

hdfs dfs -ls -R har:///user/zoo/foo.har

The following output is returned:


Note that the modified parent argument causes the files to be archived relative to /user/ rather than /user/hadoop.