Useful alias to backup and edit configuration file automatically

I’m using vim editor.

I have found useful alias to backup and edit configuration file automatically.
It can be added it to your ~/.bashrc

# User specific aliases and functions

conf() { [ "$1" != "" ] && cp -fvp "$1" "$1"-`date +%Y-%m-%d-%H-%M`.bak; vim "$1"; }

To apply newly created alias without restarting run:

# . ~/.bashrc

Usage example:

# conf /etc/httpd/conf/httpd.conf

It will create copy of /etc/httpd/conf/httpd.conf configuration file using pattern: /etc/httpd/conf/httpd.conf-YYYY-MM-DD.bak

To view your configuration changes you can run command:

# diff -Nau /etc/httpd/conf/httpd.conf-YYYY-MM-DD-HH-MM.bak /etc/httpd/conf/httpd.conf