Skip to content

Instantly share code, notes, and snippets.

@wolf0403
Last active August 27, 2015 13:12
Show Gist options
  • Save wolf0403/f73612226af365c2dcee to your computer and use it in GitHub Desktop.
Save wolf0403/f73612226af365c2dcee to your computer and use it in GitHub Desktop.
Find large file in your FS.
#!/bin/bash
export V=
check_size() {
wd=${1:-.}
indent=${2}
#echo "${indent}${wd}: "
du -h -d1 "${wd}" | (
while read line; do
size="$(echo ${line} | awk '{print $1}')"
d="$(echo ${line} | sed "s/${size}[[:space:]]//")"
if [[ "${d}" == "." ]]; then continue; fi
[ "${V}" == 'y' ] && echo "${indent}${d}: ${size}"
if ( echo ${size} | egrep -q '[MG]$' ) && test -d "${d}"; then
echo "${indent}${d}: ${size}"
(
cd "${d}"
check_size . "${indent} "
)
fi
done
)
}
check_size .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment