I am trying to display the filze size in human readable format in following find command
find $BASE_DIR/ -user $USER -size +$LOWERSIZELIMIT -mtime +$MY_MTIME -type f -printf "%s %p\n" 2> /dev/null |
sort -nr |
head -n $NUMFILES >> $TESTFILE
My function to find large files looks like this. It takes in $1 as an argument in order to pass the base directory path to the find command.
function find_files {
#echo "In find files"
# $1 = base directory from where to start the search
find $1/ -user $USER -size +$LOWERSIZELIMIT -mtime +$MY_MTIME -type f -printf "%s %p\n" 2> /dev/null | sort -nr | head -n $NUMFILES >> $TESTFILE
if [[ -s $TESTFILE ]] ;
then
echo "***********************************************************************" >> $DUMPFILE
echo "***********************************************************************" >> $DUMPFILE
echo "***********************************************************************" >> $DUMPFILE
echo "***********************************************************************" >> $DUMPFILE
#cat $TESTFILE
cat $TESTFILE >> $DUMPFILE
rm $TESTFILE
return 0
else
return 1
fi
}
$BASE_DIR/
and$1/
don’t need the trailing slashes, but they really should be in quotes, as in:find "$1" -user …