-
-
Save stojg/275dc99d148327945fbefb605b16bce9 to your computer and use it in GitHub Desktop.
find/delete corrupt whisper-files
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 | |
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