(in)frequently updated log of stuff

entertaining dozens of readers since 1997

Wednesday, April 18, 2007

cleanup.sh script

Since I enjoyed yesterday's update so much, I went ahead and wrote the garage cleaner script



#!/bin/bash
STORAGE=/home/jake/garage
CURMONTH=`/bin/date +%m`

if [ $CURMONTH -lt 6 ]
then
echo "Nothing to do - it's not June yet."
exit 0
fi

do_sortclothes()
{
USELESS=`cat $ITEM | egrep -c 'smell|hole|stains|misc_faggotry'`


if [ $USELESS -ne 0 ]
then rm -f $ITEM
else
chown nobody $ITEM
chmod 777 $ITEM
mv $ITEM /goodwill/
fi
}


find $STORAGE -user dave | while read ITEM ; do

# determine what to do with the item

case $ITEM in
*money) chown jake $ITEM ;
mv $ITEM /home/jake/ ;;

*clothes) do_sortclothes ;;

*) rm -f $ITEM ;;
esac

done

Labels:

Tuesday, April 17, 2007

The friend-o-delete-o-matic 2000

I wrote up a new script. Feel free to modify it to suit your needs. I offer consulting at very affordable rates if you're uncomfortable with bash.


#!/bin/bash
# for best results, run from cron every 1 minute

HOUSE=/home/jake

ls -1 $HOUSE | while read GUEST ; do

case $GUEST in
dave) rm -f $HOUSE/$GUEST ;;
*) ;;
esac


done

Labels: