Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I list subdirectories recursively for HDFS?

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.

like image 627
Koushik Chandra Avatar asked Jun 25 '15 17:06

Koushik Chandra


People also ask

How can I list subdirectories recursively?

Try any one of the following commands to see recursive directory listing: ls -R : Use the ls command to get recursive directory listing on Linux. find /dir/ -print : Run the find command to see recursive directory listing in Linux. du -a . : Execute the du command to view recursive directory listing on Unix.

How do I recursively list files in HDFS?

Use -R followed by ls command to list files/directorires recursively. -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.

How list all files in a directory and its subdirectories in hadoop HDFS?

Use the hdfs dfs -ls command to list files in Hadoop archives. Run the hdfs dfs -ls command by specifying the archive directory location.

How do I list only directories in HDFS?

hadoop fs -ls -R command list all the files and directories in HDFS. grep “^d” will get you only the directories.


1 Answers

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
like image 102
Farooque Avatar answered Jan 03 '23 19:01

Farooque