#!/bin/sh # v 0.4 # script to remove the cache files added during the last run of ut2004 # add the following to run prior to any ut2004 game: # --- >% --- # cache=~/.ut2004/Cache # # cp $cache/cache.ini $cache/mark-`date +%F_%H.%M.%S`; touch $_ # # i=8 # [ `ls $cache/mark-* | wc -l` -ge ${i[0]} ] && ((j=`ls $cache/mark-* | nl | \ # tail -${i[0]} | head -1 | cut -f1`-1)) && rm -f `ls $cache/mark-* | head -$j` # --- >% --- # Note: all this is not whitespace safe! ch=~/.ut2004/Cache ctmp=/tmp/.$$.cache.ini cd "$ch" || exit 1 i=(`ls -td * | nl | awk --assign ctmp=$ctmp '/mark-/ { print; system("cp "$2" "ctmp); exit }'`) [ ${i[0]} -ge 0 -a -e $ctmp ] || { echo "No mark-... cache.ini backup found, exiting"; exit 1; } #echo rm -f `ls -tr | tail -${i[0]}` rm -f `ls -tr | tail -${i[0]}` #echo mv $ctmp $ch/cache.ini; rm -f $ctmp mv $ctmp $ch/cache.ini echo "Reverted to cachestate of ${i[1]##mark-}"