Skip to content

Instantly share code, notes, and snippets.

@tripleee
Last active August 29, 2015 14:07
Show Gist options
  • Save tripleee/f085ae3d4b7650b33c67 to your computer and use it in GitHub Desktop.
Save tripleee/f085ae3d4b7650b33c67 to your computer and use it in GitHub Desktop.
Create backups with successively more tildes
# Source this file
bak () {
# "local" is a Bashism -- comment out for POSIX
local f
for f; do
test -e "$f~" && bak "$f~"
mv "$f" "$f~"
done
}
kab () {
local f
for f; do
case $f in *'~') mv -v -i "$f" "${f%'~'}" || break;; esac;
test -e "$f~" && kab "$f~"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment