HDFS: How do you list files recursively?

前端 未结 3 751
梦毁少年i
梦毁少年i 2021-02-12 11:26

How do you, through Java, list all files (recursively) under a certain path in HDFS. I went through the API and noticed FileSystem.listFiles(Path,boolean) but it looks like that

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-12 12:22

    Use -R followed by ls command to list files/directorires recursively.

    hadoop fs -ls -R Path/Of/File
    

    Possible attributes for ls command are

    -d : Directories are listed as plain files.

    -h "Formats the sizes of files in a human-readable fashion rather than a number of bytes.

    -R "Recursively list the contents of directories.

提交回复
热议问题