Created
September 22, 2016 20:54
-
-
Save v6/f8257bf027a0ef54163031a15345a5e3 to your computer and use it in GitHub Desktop.
// , This has some super neato functions you can use as aliases elsewhere.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nathan's Backup function. | |
# It's best to create backup files by moving the original file aside to its new name with mv and the ncopying it back to its original name. | |
# cp -p preserves original file's set attributes. | |
# mv and cp -p preserve the original file's settings like the time it was created and modified. | |
# Also, be advised, processes might have an open reference to the original file. This process will not cause them errors. Be aware of this, if you are expecting errors from those files. | |
# This defines a backup bash function bakmvcp that timestamps a new file name and does the switch for you. | |
function bakmvcp () { | |
newname=$1.`date +%Y%m%d.%H%M.bak`; | |
mv $1 $newname; | |
echo "Backed up $1 to $newname."; | |
cp -p $newname $1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment