How to find large file size on linux
Often time, you may need to know which file contains large file size, and delete it to save space. Here’s a code pattern to show you how to find large file size on Linux :
find {directory} -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
1. File size >= 100MB
Find all files that have a size >= 100MB, from root folder and its sub-directories.
sudo find / -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
Result
/Applications/Diablo: 2.3G
/Applications/Diablo: 203M
/Applications/Diablo: 978M
/Applications/Diablo: 1.4G
/Applications/Diablo: 1.3G
/Applications/Diablo: 1.5G
/Applications/iPhoto.app/Contents/Resources/PointOfInterest.db: 242M
2. File size >= 50MB
Find all files that have a size >= 50MB, from folder ‘/Users/mkyong’ and its sub-directories.
find /User/mkyong -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
Result
/Users/mkyong/Downloads/command_line_tools_for_xcode_june_2012.dmg: 147M
/Users/mkyong/Downloads/ubuntu-12.04-desktop-i386.iso: 701M
/Users/mkyong/Downloads/X15-65805.iso: 3.0G
/Users/mkyong/Library/Preferences/com.google.code.sequel-pro.plist: 104M