eriksmartt.com>Selected Archives

Lifehack entry number one

In the lifehacker spirit of sharing tips and tricks that help simplify one's daily routine, I've added a lifehack category to my blog. For the first entry I thought I'd start with this super simple shell function I have in my .bash_profile to make a time-stamped copy of a file. Before writing this, if I wanted to edit a config file I would generally make a copy and append '.old' to the file name. However, the next time you want to change it you're stuck wasting time figuring out what to name the next revision. To address that, this function adds a shell command called 'bak' that will make a quick copy of a file and add a date-stamp to the file name.

function bak {   TIMESTAMP=date "+%y%m%d_%H%M"   cp $1 $1.$TIMESTAMP }