utility-option

mv -T

GNU mv treats TARGET as one path, not a directory to move into. Same-filesystem rename can be atomic but is not guaranteed crash durable.

Formal Syntax & Structure

bash syntaxbash
mv -T -- SOURCE TARGET

Return Value

exit status

GNU mv treats TARGET as one path, not a directory to move into. Same-filesystem rename can be atomic but is not guaranteed crash durable.

Working Example

Example Snippetbash
umask 077printf 'mode=dev\n' > app.confupdate() (    local_candidate=$(mktemp ./candidate.XXXXXXXX) || exit 1    trap 'rm -f -- "$local_candidate"' EXIT    printf 'mode=test\n' > "$local_candidate" || exit 1    cmp -s "$local_candidate" app.conf    case $? in        0) printf 'unchanged\n'; exit 0 ;;        1) mv -T -- "$local_candidate" app.conf || exit 1 ;;        *) exit 2 ;;    esac    printf 'updated\n')update || exit 1first=$(stat -c '%i' app.conf) || exit 1update || exit 1[[ $(stat -c '%i' app.conf) == "$first" ]] || exit 1cat app.conf
Bash Reference