Hi,
I want to list the files from a directory in HDFS. How to list files in hadoop?
Thanks
Hi,
Hadoop uses its own file system which is know as Hadoop File System or HDFS.
Hadoop provides commands to interact with the HDFS. To list down all the file in a directory you can use the following command:
hadoop fs -ls /
Above command lists all the files from the root of HDFS.
Sample output:
hdfs@hadoop1:/home/deepak$ hadoop fs -ls / Found 11 items drwxrwxrwx - yarn hadoop 0 2017-05-13 18:33 /app-logs drwxr-xr-x - hdfs hdfs 0 2016-04-26 19:30 /apps drwxr-xr-x - yarn hadoop 0 2016-04-25 20:57 /ats drwxr-xr-x - hdfs hdfs 0 2016-04-25 20:58 /hdp drwxr-xr-x - mapred hdfs 0 2016-04-25 20:58 /mapred drwxrwxrwx - mapred hadoop 0 2016-04-25 20:58 /mr-history drwxrwxrwx - spark hadoop 0 2017-05-13 19:26 /spark-history drwxr-xr-x - hdfs hdfs 0 2017-05-13 10:51 /system drwxr-xr-x - hdfs hdfs 0 2017-05-11 22:52 /test drwxrwxrwx - hdfs hdfs 0 2016-04-25 21:02 /tmp drwxr-xr-x - hdfs hdfs 0 2017-05-13 18:33 /user hdfs@hadoop1:/home/deepak$
Check more at Hadoop shell commands.
Thanks
Ads