/usr/portage

Easily backup files 0

Since today I have a very practical backup-function in my /etc/profile. I dont’t want to withhold it from you:
function backup () { DATE=$(date +%Y-%m-%d-%H:%M) if [ `echo $1 | grep "\."` ] then BU=$(echo $1 | sed -e "s/\(.*\)\(\..*$\)/\1-$DATE\2/g") else BU="$1-$DATE" fi if [ -e "$1" ] | [ ! -e "$BU" ] then cp $1 $BU else echo "$1: No such file or Directory" fi }
You can use this function by typing backup $filename. Then a copy of $filename will be created which is named in this style orginalname-date.ext.

Filed under , , , & no comments & no trackbacks

Trackbacks

Trackback specific URI for this entry

No Trackbacks

Comments

No comments

Add a Comment & let me know what you think