我有一组在HDFS中递归创建的目录,如何列出所有目录?对于普通的Unix文件系统,我可以使用以下命令来完成:
find /path/ -type d -print
但是我想要类似的东西来处理HDFS。
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
@Shubhangi Pardeshi提供的答案是正确的,但对于最新的Hadoop版本,该命令已被弃用。因此,可以使用下面的最新命令。
hdfs dfs -ls -R /user | grep drwx
hdfs dfs -ls -R /folder | grep "^d"