Find /list all files bigger than 5MB and delete them in command line for linux/mac

find . -type f -size +3000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’

./Uploads/Page-Photos/About-Us/9653a21167/DSCN1703.JPG: 3.3M
./Uploads/103eca7540/tori.jpg: 4.4M
./Uploads/845d819c4d/FCU-157_master.jpg: 4.1M
./Uploads/PDF-Forms/Annual-Reports/fe6ddf67be/First-Credit-Union-Annual-Report-2015.pdf: 19M
./Uploads/PDF-Forms/Annual-Reports/802f311485/First-Credit-Union-Annual-Report-2018.pdf: 3.0M

 

$ find . -type f -size +3000k -exec ls -lh {} \;
-rw-r–r– 1 xx staff 6.3M 4 Jun 09:21 ./Images/Promotions/eace8a9a35/Staff-1.jpg
-rw-r–r– 1 xx staff 14M 4 Jun 09:21 ./Images/Promotions/293eed50a8/Christmas-Club.jpg
-rw-r–r– 1 xx staff 4.0M 4 Jun 09:21 ./Images/Promotions/f9ec6b2d93/Travel-Account.png
-rw-r–r– 1 xx staff 8.7M 4 Jun 09:21 ./Images/Promotions/682ea47e1d/community-about-us.jpg
-rw-r–r– 1 xx staff 3.0M 4 Jun 09:21 ./Images/Promotions/efe514b1dd/loan-provider.png
-rw-r–r– 1 xx staff 6.5M 4 Jun 09:21 ./Images/Promotions/1372a11660/Board-of-Directors-and-TGA-Managers.jpg

find . -type f -size +3000k -exec ls -lh {} \; -delete

 

Leave a Reply

Your email address will not be published. Required fields are marked *