How can I list subdirectories recursively for HDFS?

I have a set of directories created in HDFS recursively. How can I list all directories? For a normal unix file system, I can do this using the following command

find /path/ -type d -print 

But I want to get similar for HDFS.

+5
source share
2 answers

You can use the hadoop dfs -lsr /dirname command recursively to display the contents of a directory.

To filter directories only, you can grep "drwx" (since the owner has rwx permission for directories) in the output of the command above.

Therefore, the whole team will look like the one shown below.

 $hadoop dfs -lsr /sqoopO7 | grep drwx 
+4
source

The answer given by @Shubhangi Pardeshi is correct, but the version is outdated for the latest suoop command. So the new last command can be used as below

 hdfs dfs -ls -R /user | grep drwx 
+3
source

All Articles