Created
February 8, 2020 09:33
-
-
Save letam/98596ed3d7e97094a4b716241e5abe03 to your computer and use it in GitHub Desktop.
bash functions
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
| #!/usr/bin/env bash | |
| # Utility functions to use in bash shell and scripts | |
| # backup file | |
| function bak() { mv $1 $1.bak && cp -p $1.bak $1 ;} | |
| function su_bak() { sudo mv $1 $1.bak && sudo cp -p $1.bak $1 ;} | |
| # backup file with date | |
| function bakd() { v="$1.bak.`date -u +%Y-%m-%d-%H%M%S`" ; mv $1 $v && cp -p $v $1 ;} | |
| function su_bakd() { v="$1.bak.`date -u +%Y-%m-%d-%H%M%S`" ; sudo mv $1 $v && sudo cp -p $v $1 ;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment