scripts

My personal collection of scripts
git clone git://src.gearsix.net/scripts
Log | Files | Refs | Atom | README | LICENSE

commit eb3e76ad3bb53cf1c24edc9d757806a7654b001a
parent 5555668bb24285fd1a65032ead3bd56fbcf46deb
Author: gearsix <gearsix@tuta.io>
Date:   Mon, 26 Jul 2021 16:27:16 +0100

added -r to backup

Diffstat:
Msrc/backup.sh | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/backup.sh b/src/backup.sh @@ -4,11 +4,17 @@ # e.g.$ backup ~/.bashrc ~/.vimrc if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then - echo "Usage: 'backup FILEPATHS...'" + echo "Usage: 'backup [OPTIONS] FILEPATHS...'" echo "" echo "copy all listed files (in FILEPATHS...) to \$filename.bak" + echo "" + echo "OPTIONS (must be provided before FILEPATHS...)" + echo " -r move files instead of copying them, removing the original" exit fi -for f in ${@}; do cp $f $f.bak; done +backup=cp +if [ "$1" == "-r" ]; then backup=mv; fi + +for f in ${@}; do $backup $f $f.bak; done