Sort Files According To Their Size

With few basic commands in Linux box, we can generate a report of files according to ascending or descending order of their size.

Let's start by displaying all the files from a folder:
find ~/testFolder -type -f 
To get their size lets pass each file to du command:
find ~/testFolder -type -f -exec du -s {} \;
Now lets sort them according to their size in numeric order, taking first column as file size and in reverse order:
find ~/testFolder -type -f -exec du -s {} \; | sort -k1nr
Let's save the output to a file size.txt:
find ~/testFolder -type -f -exec du -s {} \; | sort -k1nr > ~/size.txt 

Comments

Popular posts from this blog

Perm Root HTC Desire Gingerbread 2.3.3

[Solved] invalid partition table on /dev/sda -- wrong signature 0.

Adobe Stand Alone Flash Player for Linux