如何递归列出 HDFS 的子目录? [英] How can I list subdirectories recursively for HDFS?

查看:31
本文介绍了如何递归列出 HDFS 的子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组在 HDFS 中递归创建的目录.如何列出所有目录?对于普通的 unix 文件系统,我可以使用以下命令

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

但我想为 HDFS 获得类似的东西.

But I want to get the similar thing for HDFS.

推荐答案

递归列出目录内容可以使用 hadoop dfs -lsr/dirname 命令.

要仅过滤目录,您可以在上述命令的输出中 grep "drwx"(因为所有者对目录具有 rwx 权限).

因此整个命令如下所示.

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 

这篇关于如何递归列出 HDFS 的子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆