The -u option in the mv command stands for "update." When you use this option, it only moves the source file to the destination if the source file is newer than the destination file or if the destination file does not exist.
Behavior:
- If the destination file exists and is older than the source file, the source file will be moved, replacing the destination file.
- If the destination file exists and is newer than the source file, the move will not occur.
- If the destination file does not exist, the source file will be moved.
Example:
mv -u source.txt destination/
In this case, source.txt will only be moved to destination/ if it is newer than destination/source.txt or if destination/source.txt does not exist.
This option is useful for keeping files updated without overwriting newer versions.
