Skip to content

Instantly share code, notes, and snippets.

@kauhat
Last active August 29, 2015 14:24
Show Gist options
  • Save kauhat/9b6896356c64b5e2e74b to your computer and use it in GitHub Desktop.
Save kauhat/9b6896356c64b5e2e74b to your computer and use it in GitHub Desktop.
Find large "error_log" files
#!/bin/sh
workdirname="error-logs";
mkdir -p ${workdirname};
workdir=$(cd $workdirname; pwd);
echo "Finding all error_log files"
find /home -maxdepth 16 -name "error_log" -exec echo -n -e {}"\0" \; \
| du -hc --files0-from=- \
> ${workdir}/.unsorted.txt;
echo "Sorting by size"
cat ${workdir}/.unsorted.txt | sort -h \
> ${workdir}/processed.txt;
echo "Written output to \"${workdir}/processed.txt\".";
#Clean up
rm ${workdir}/.unsorted.txt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment