Skip to content

Instantly share code, notes, and snippets.

@stojg
Forked from codepunkt/rm-corrupt.sh
Last active October 4, 2016 05:27
Show Gist options
  • Save stojg/275dc99d148327945fbefb605b16bce9 to your computer and use it in GitHub Desktop.
Save stojg/275dc99d148327945fbefb605b16bce9 to your computer and use it in GitHub Desktop.
find/delete corrupt whisper-files
#!/bin/bash
options=('find' 'delete')
PS3='state your wish: '
echo -e "\nfind/delete corrupt whisper-files"
select opt in "${options[@]}"; do
case $REPLY in
[12] ) option=$opt; break;;
* ) exit;;
esac
done
if [ $option ]; then
matches=()
directory='/var/graphite/'
for file in $(find $directory -type f -name '*.wsp' -print); do
/usr/local/bin/whisper-info.py "$file" > /dev/null 2>&1
retval=$?
if [ $retval -ne 0 ]; then
printf "\r\033[Kcorrupt $file\n"
if [ $option == 'delete' ]; then
find "$file" -type f -delete
fi
else
echo -ne "\r\033[Kchecked $file"
fi
done
fi
echo "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment