log and xac files
Thomas Spahni
tsp@lawbiz.ch
Fri, 30 Mar 2001 10:54:59 +0200 (CEST)
On Mon, 26 Mar 2001, Rich Shepard wrote:
> What do folks do with the collection of *log and *xac files that accrue in
> the gnucash data directory? Are they ever incorporated into the base data
> file? Do I just rm them now and then?
>
> I'd appreciate suggestions for what to do about them (including, ignore
> them).
Rich,
*xac are good as a backup (but still on the same disk in case of a crash).
I delete all *.log files and do run the following bash-script once in a
while :-)
Thomas
---- snip -------
#!/bin/sh
# Remove old *.xac backup files
# Default is to keep backups for the last seven days
# any other number of days may be given as an argument
# on the command line.
DAYSTOKEEP=7
if test -n "$1" ; then
HOWMANYDAYS=$(echo "$1" | sed -e "s/[^0-9]//g")
if test $[$HOWMANYDAYS] -gt $[0] ; then
DAYSTOKEEP=$HOWMANYDAYS
else
echo "Usage: Remove_old_backups.sh [#of_days_to_keep]"
exit 1
fi
fi
# Limit is a string of format YYYYMMDDHHMMSS
LIMIT=$(date -d "$DAYSTOKEEP days ago" '+%Y%m%d%H%M%S')
# this will not work for filenames containing characters
# with any special meaning for bash or sed.
# However, filenames may contain dots
for xacfile in *.xac ; do
LEADTAG=$(echo "$xacfile" | sed \
-e 's/\.xac$//' -e 's/2[0-9][0-9]*$//' -e 's/\./\\\\./g')
DATETAG=$(echo "$xacfile" | sed -e 's/\.xac$//' -e "s/^$LEADTAG//")
if [ "$DATETAG" '<' "$LIMIT" ] ; then
echo "removing $xacfile"
rm -f "$xacfile"
fi
done