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:
har:///user/zoo/foo.har/dir1 har:///user/zoo/foo.har/dir2
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:
har:///user/zoo/foo.har/hadoop har:///user/zoo/foo.har/hadoop/dir1 har:///user/zoo/foo.har/hadoop/dir2
Note that the modified parent argument causes the files to be archived relative to
/user/
rather than /user/hadoop
.