I have the following code to find specific files that are over 10 MB:
[[ -n "$1" ]] || { echo "Usage: findlarge [PATHNAME]"; exit 0 ; }
FILES=`find $1 -type f -size +10000k -exec ls -lh {} \; | awk '{ print $9 ";" }'`
echo -ne $FILES
It works quite well until it runs into a file path that has a space in it. So for example I have a folder that has a large file in it at /var/www/html/Web Content/largefile.zip but the script will only return /var/www/html/Web.
Any ideas how to fix that?
Put your
$1into quotes to handle the space, and use the-printfargument to output your file list:Using
;to match your existing code, but you can substitute\nto output each file on its own line.