Section 5: 35. Listing Files in HDFS

To list the files and directories in HDFS, you can use the “ls” command with the “hadoop fs” or “hdfs dfs” command line interface.

hadoop fs  -ls -C    Display the paths of files and directories only.

hadoop fs  -ls -d     Directories are listed as plain files.

hadoop fs  -ls  -h     Formats the sizes of files in a human-readable fashion rather than a no of byte

hadoop fs  -ls  -q     Print ? instead of non-printable characters.

hadoop fs  -ls  -R    Recursively list the contents of directories.

hadoop fs  -ls  -t      Sort files by modification time (most recent first).

hadoop fs  -ls  -S      Sort files by size,

hadoop fs  -ls  -r      Reverse the order of the sort.

hadoop fs  -ls  -u     Use time of last access instead of modification for display-and-sorting.

Share this post