#!/bin/sh bakrotate() { if [ -f $1 ] then if [ -f "$1.bak" ] then bakrotate "$1.bak" fi mv "$1" "$1.bak" fi } bakrotate "$1.bak" cp $1 $1.bak