Making system administration easier

22. October, 2010

I you ever wondered what a file looked like before you edited it, this script is for you:

#!/bin/bash

dir=$(pwd)

for f ; do
        if [[ -e "$f" ]]; then
                path=$(cd $(dirname "$f") ; pwd)
                mkdir -p "/root/vibak/$path"
                cp -p "$f" "/root/vibak/$path/$(basename "$f")-$(date +"%Y%m%d-%H%M%S")"
        fi
done

exec /usr/bin/$(basename $0) "$@"

Then create links to it from $HOME/bin/vi, vim, gvim, edit, nano, ...

Remember: Never remember anything your computer can remember for you.