Making system administration easier

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s