Skip to content

Instantly share code, notes, and snippets.

@offbeatadam
Created January 27, 2012 22:06
Show Gist options
  • Save offbeatadam/1691182 to your computer and use it in GitHub Desktop.
Save offbeatadam/1691182 to your computer and use it in GitHub Desktop.
archiving irssi logs
#!/bin/bash
ROOTDIR="/home/triton/.irssi"
LOGDIR="$ROOTDIR/logs"
ARCHIVE="$ROOTDIR/logs.old"
printf "Beginning log archiving\n"
printf "Moving to log directory %s\n" "$LOGDIR"
cd $LOGDIR
for i in `ls -A`
do
if [ -d $i ]
then
printf "Moving to log subdirectory %s\n" "$i"
cd $LOGDIR/$i
for j in `ls -A`
do
if [ -d $j ]
then
printf "Current Working Directory: %s/%s/%s\n" "$LOGDIR" "$i" "$j"
cd $LOGDIR/$i/$j
for k in `find $PWD -type f -atime +7 -printf "%p\n"`
do
printf "Archiving File %s to %s/%s/%s\n" "$k" "$ARCHIVE" "$i" "$j"
cp -v "$k" "$ARCHIVE/$i/$j"
done
fi
done
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment