2020-01-16 18:16:39 -07:00
|
|
|
#!/bin/bash
|
|
|
|
# wut-rm-random
|
|
|
|
#
|
|
|
|
# Does a coin flip to decide whether to remove a file or not.
|
|
|
|
# Runs on directory specified below.
|
|
|
|
#
|
|
|
|
# XXX This script removes files and directories in data/ !!! XXX
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# wut-rm-random
|
|
|
|
# Example:
|
|
|
|
# wut-rm-random
|
|
|
|
|
|
|
|
# NOTE:
|
|
|
|
# In current unvetted-CW-8k dir:
|
|
|
|
# 129*-132* = good
|
|
|
|
# 133*-135* = bad
|
|
|
|
|
|
|
|
# Number of waterfalls to keep:
|
2020-01-16 18:19:43 -07:00
|
|
|
KEEP=100
|
2020-01-16 18:16:39 -07:00
|
|
|
|
2020-01-16 18:25:54 -07:00
|
|
|
# this is so bad no one should ever run it again
|
2020-01-16 19:25:44 -07:00
|
|
|
#exit 0
|
2020-01-16 18:16:39 -07:00
|
|
|
# XXX Delete data in this directory! XXX
|
2020-01-26 17:27:12 -07:00
|
|
|
cd /srv/satnogs/data/test/unvetted/ || exit
|
2020-01-16 18:16:39 -07:00
|
|
|
|
|
|
|
TOTALFILES=`ls waterfall_*.png | wc -l`
|
|
|
|
for wf in waterfall_*.png
|
|
|
|
do \
|
|
|
|
if [ $TOTALFILES -gt $KEEP ] ; then
|
|
|
|
RANDFLIP=`echo $((0 + RANDOM % 2))`
|
|
|
|
if [ $RANDFLIP = 1 ] ; then
|
2020-01-16 18:19:43 -07:00
|
|
|
rm -f $wf &
|
2020-01-16 18:16:39 -07:00
|
|
|
fi
|
|
|
|
let TOTALFILES=`ls waterfall_*.png | wc -l`
|
|
|
|
else break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|