Last active
August 27, 2015 13:12
-
-
Save wolf0403/f73612226af365c2dcee to your computer and use it in GitHub Desktop.
Find large file in your FS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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