dotfiles/.local/bin/scripts/bak

10 lines
189 B
Plaintext
Raw Normal View History

#!/bin/sh
2021-07-04 16:20:36 +00:00
suffix="${2:-bak}"
2021-07-04 19:56:12 +00:00
orig="${1%%.$suffix}"
if test -e "$orig.$suffix"
then
test -e "$orig" && mv -v "$orig" /tmp
mv -vn "$orig.$suffix" "$orig"
else mv -vn "$1" "$1.$suffix"
fi