megacolorboy

Back

Published on September 20th, 2021

Linux

Display list of files with their extension and file sizes

Last month, I was trying to free up some space in my company servers and I realized that there were a lot of files taking up a lot of space.So, I wrote the following command to list files by their extension:And later to determine which files are the largest, I executed this command to sort the list by file size:Hope this tip helps you too! 😄

1 minute read

Last month, I was trying to free up some space in my company servers and I realized that there were a lot of .zip files taking up a lot of space.

So, I wrote the following command to list files by their extension:


find . -iname \*.extension -exec du -sh {} \; > file-list.txt

And later to determine which files are the largest, I executed this command to sort the list by file size:


sort -rh file-list.txt > newfile.txt

Hope this tip helps you too! 😄