Quote:
Originally Posted by investmentbnker75
I have a directory that keeps filling up and i need to clean it up. So i want to find large files i can possibly delete. I need a find command or shell script that will find large files over 500m and sort them with the largest at the top.
Im using one that isnt working very well:
#!/bin/bash
# if nothing is passed to the script, show usage and exit
[[ -n "$1" ]] || { echo "Usage: findlarge [PATHNAME]"; exit 0 ; }
# simple using find, $1 is the first variable passed to the script
find $1 -type f -size +520000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
Thanks
|
How about trying
find $1 -type f -size +520000k -exec ls -l {} \; | awk '{ print $5 " " $9 }' | sort -nr
this will do a reverse numeric sort
BTW: don't forget that space is freed only when no more processes are accessing the file.