looqs/delindex
2018-01-03 09:40:13 +01:00

22 lines
379 B
Bash
Executable File

#!/bin/sh
TEMPFILE=$(mktemp)
DBFILE="/home/db/easyindex.sqlite"
function todelete()
{
echo "DELETE FROM file WHERE path = '$1';" >> /"$TEMPFILE"
}
echo "BEGIN TRANSACTION;" >> /"$TEMPFILE"
sqlite3 "$DBFILE" "SELECT path FROM file;"| while read line ; do
[ -e "$line" ] || todelete "$line"
done
echo "COMMIT TRANSACTION;" >> /"$TEMPFILE"
sqlite3 "$DBFILE" < /"$TEMPFILE"