mvrename and move files and directories |
Command |
mv
[-dfiv
] file1 file2
mv
[-fiv
] file ... directory
mv
-r
[-fiv
]
directory1 directory2
mv
renames files or moves them to a different directory. If
you specify multiple files, the target (that is, the last path name on
the command line) must be a directory. mv
moves the files
into that directory and gives them names that match the final components of the
source path names. When you specify a single source file and the target
is not a directory, mv
moves the source to the new name, by
a simple rename if possible.
If a destination file exists and you do not have write permission for it,
mv
prompts with the name of the existing file. If you answer
y
or yes
, it deletes the destination and then moves
the source.
-d
delays moving the specified files until the system is rebooted.
This option relies upon the underlying operating system's capability to perform the action at reboot time.
-f
does not ask if you want to overwrite an existing destination without
write permission; it automatically behaves as if you answered
yes
. If you specify both -f
and
-i
, mv
uses the option that
appears last on the command line.
-i
always prompts before overwriting an existing file, whether or not the
file is read-only. If you specify both -f
and
-i
, mv
uses the option that
appears last on the command line.
-r
moves directory and all its contents (files, subdirectories, files in
subdirectories, and so on). For example, mv -R dir1 dir2
moves the entire contents of dir1
to dir2/dir1
.
mv
creates any directories that it needs.
-v
prints file names to standard output as they are being processed.
0
Successful completion.
1
Failure due to any of the following:
/
) but was not a
directory-r
option-r
errors include the following:
2
Failure due to any of the following:
mv
has no space to hold the name of the target
file. Try to free up some memory to give mv
more
space.
You are attempting to move a file, but there is already a file with the
target name and the file is read-only. If you really want to write over
the existing file, type y
and press ENTER. If you do not want
to write over the existing file, type n
and press ENTER.
The source and the target are actually the same file (for example,
because of links on UNIX and POSIX-compliant systems). In this case,
mv
does nothing.
mv
cannot read the specified directory (for example,
because you do not have appropriate permissions).
-d
, -r
, and -v
options are extensions to the POSIX standard.