Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List directories (and their subdirectories) with hadoop command line

is there any way to list only directories and their directories recursively with the hadoop command line?

I was wondering if there is some kind of command similar to the unix command:

find /tmp -type d -print

like image 536
Ivan Fernandez Avatar asked May 04 '15 10:05

Ivan Fernandez


People also ask

How do I list directories in hadoop?

The following arguments are available with hadoop ls command: Usage: hadoop fs -ls [-d] [-h] [-R] [-t] [-S] [-r] [-u] <args> Options: -d: Directories are listed as plain files. -h: Format file sizes in a human-readable fashion (eg 64.0m instead of 67108864). -R: Recursively list subdirectories encountered.

How do I view a directory in HDFS?

To browse the HDFS file system in the HDFS NameNode UI, select Utilities > Browse the file system . The Browse Directory page is populated. Enter the directory path and click Go!.

What is the command to list files in a Hdfs directory?

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 find my current directory in hadoop?

Using the ls command, we can check for the directories in HDFS. Hadoop HDFS mkdir Command Description: This command creates the directory in HDFS if it does not already exist. Note: If the directory already exists in HDFS, then we will get an error message that file already exists.


2 Answers

Try this as well: (listing directories from root)

hadoop fs -ls -R / | grep "^d"
like image 200
sras Avatar answered Oct 17 '22 06:10

sras


Try using this command

hdfs dfs -ls hdfs:/
like image 23
Wee kah huat Avatar answered Oct 17 '22 06:10

Wee kah huat