How can I list subdirectories recursively for HDFS?

对着背影说爱祢 提交于 2019-12-21 12:57:51

问题


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

find /path/ -type d -print

But I want to get the similar thing for HDFS.


回答1:


To list directory contents recursively hadoop dfs -lsr /dirname command can be used.

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

Hence whole command will look like as below.

$hadoop dfs -lsr /sqoopO7 | grep drwx 



回答2:


The answer given by @Shubhangi Pardeshi is correct but for latest hadoop version command has deprecated. So new latest command can be used as below

hdfs dfs -ls -R /user | grep drwx


来源:https://stackoverflow.com/questions/31056680/how-can-i-list-subdirectories-recursively-for-hdfs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!