Forrest logo
back to the mv tool

mv:tldr:df81d

mv: Do not overwrite existing files at the target.
$ mv -n ${path-to-source} ${path-to-target}
try on your machine

The command "mv -n ${path-to-source} ${path-to-target}" is used to move a file or directory from one location to another.

Here's the breakdown of the command:

  • "mv" is the command for moving files or directories in Unix-like operating systems (such as Linux).
  • "-n" is an optional argument that stands for "no-clobber". It prevents overwriting an existing file with the same name in the target location. If a file with the same name already exists in the target directory, the command will not overwrite it, and the file will retain its original location.
  • "${path-to-source}" represents the path to the file or directory you want to move. It should be replaced with the actual path to the source file or directory.
  • "${path-to-target}" represents the path to the destination where you want to move the file or directory. It should be replaced with the actual path to the target directory.

To use this command, replace "${path-to-source}" and "${path-to-target}" with the actual paths. For example:

mv -n /home/user/file.txt /home/user/documents/

This will move the file "file.txt" from the /home/user/ directory to the /home/user/documents/ directory, using the -n option to avoid overwriting any existing file with the same name in the target directory.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the mv tool