15 lines
279 B
Bash
Executable File
15 lines
279 B
Bash
Executable File
#!/bin/sh
|
|
suffix="${2:-bak}"
|
|
orig="${1%%.$suffix}"
|
|
smv () {
|
|
eval source=\$$(($#-1))
|
|
test -w "$source" && mv -v "$@" || sudo mv -v "$@"
|
|
}
|
|
if test -e "$orig.$suffix"
|
|
then
|
|
test -e "$orig" && smv "$orig" /tmp
|
|
smv -n "$orig.$suffix" "$orig"
|
|
else
|
|
smv -n "$1" "$1.$suffix"
|
|
fi
|