Wednesday 23 March 2022

Hadoop: ls: Print files by their size

‘hadoop fs -ls -S’ command print the files by descending order of their size (File with bigger size will come first).

$hadoop fs -ls -S /user/cloudera/demo1
Found 6 items
-rw-r--r--   1 cloudera cloudera    9147128 2022-03-22 23:57 /user/cloudera/demo1/atlasClient.docx
-rw-r--r--   1 cloudera cloudera    8986359 2022-03-22 23:58 /user/cloudera/demo1/maven.docx
-rw-r--r--   1 cloudera cloudera    6988969 2022-03-22 23:58 /user/cloudera/demo1/gradle.docx
-rw-r--r--   1 cloudera cloudera    6166736 2022-03-22 23:57 /user/cloudera/demo1/atlas.docx
-rw-r--r--   1 cloudera cloudera    4724690 2022-03-22 23:57 /user/cloudera/demo1/apacheNifi.docx
-rw-r--r--   1 cloudera cloudera          2 2022-03-22 23:58 /user/cloudera/demo1/a.txt

 Use -r option to print the files in ascending order of their size.

$hadoop fs -ls -S -r /user/cloudera/demo1
Found 6 items
-rw-r--r--   1 cloudera cloudera          2 2022-03-22 23:58 /user/cloudera/demo1/a.txt
-rw-r--r--   1 cloudera cloudera    4724690 2022-03-22 23:57 /user/cloudera/demo1/apacheNifi.docx
-rw-r--r--   1 cloudera cloudera    6166736 2022-03-22 23:57 /user/cloudera/demo1/atlas.docx
-rw-r--r--   1 cloudera cloudera    6988969 2022-03-22 23:58 /user/cloudera/demo1/gradle.docx
-rw-r--r--   1 cloudera cloudera    8986359 2022-03-22 23:58 /user/cloudera/demo1/maven.docx
-rw-r--r--   1 cloudera cloudera    9147128 2022-03-22 23:57 /user/cloudera/demo1/atlasClient.docx

 



Previous                                                 Next                                                 Home

No comments:

Post a Comment