Linux Scroll

Just another WordPress.com site

How to find 10 largest files in linux

Find 10 largest files more than 100MB in root:

$ find / -xdev -type f -size +100000000c -exec du -sh {} \; | awk '{ print $9 ": " $5 }'

$ find / -xdev -type f -size +100M -exec ls -la {} \; | sort -nk 5
$ find / -xdev -type f -size +100M -exec ls -la {} \; | sort -n -r | head -n 10

Display files from smallest to largest:
$ find / -xdev -type f -size +1000000c -exec ls -la {} \; 2>/dev/null| sort +4n | tail -10

Display files from largest to smallest:
$ find / -xdev -type f -size +1000000c -exec ls -la {} \; 2>/dev/null| sort +4nr | head -10

-xdev  Don't descend directories on other filesystems.

To list 10 largest files in human readable format:

$ du -h / | sort -h -r | head -n 10

$ # du -sh / | grep [4-9][0-9][0-9]M

du - estimate file space usage

-a = all
-h = human-readable
-s = summarize

head - output first part of file
-n = print first n line

sort - sort lines of text files
-i = ignore-nonprinting
-h = human-numeric-sort
-n = numeric-sort
-r = reverse the result of comparisons
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: