scripts/find_big_files.sh

23 lines
504 B
Bash
Executable file

#!/bin/sh
# Author: Oliver Ladner <oli@lugh.ch>
# License: LGPL
#
# Find and report big files
MIN_SIZE="$1M"
DIRS="/usr /home /etc /bin /var /sbin /tmp"
EXCLUDE=""
# df
DF=$(df -h)
if [ ! $1 ]; then
echo "Usage: $0 <number-in-mb>"
exit 1
else
DO_IT=`find $DIRS -size +$MIN_SIZE -print -exec ls -lha {} \; | grep -v '$EXCLUDE' | awk {'print $5"\t"$6" "$7" "$8'}`
LOL=`echo $DO_IT | wc -l`
if [ "$LOL" -gt "0" ]; then
echo "$DO_IT"
fi
fi