www.delorie.com/gnu/docs/textutils/coreutils_67.html   search  
Buy GNU books!

GNU Core-utils

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.4 mv: Move (rename) files

mv moves or renames files (or directories). Synopsis:

mv [option]... source dest
mv [option]... source... directory

If the last argument names an existing directory, mv moves each other given file into a file with the same name in that directory. Otherwise, if only two files are given, it renames the first as the second. It is an error if the last argument is not a directory and more than two files are given.

mv can move any type of file from one filesystem to another. Prior to version 4.0 of the fileutils, mv could move only regular files between filesystems. For example, now mv can move an entire directory hierarchy including special device files from one partition to another. It first uses some of the same code that's used by cp -a to copy the requested directories and files, then (assuming the copy succeeded) it removes the originals. If the copy fails, then the part that was copied to the destination partition is removed. If you were to copy three directories from one partition to another and the copy of the first directory succeeded, but the second didn't, the first would be left on the destination partition and the second and third would be left on the original partition.

If a destination file exists but is normally unwritable, standard input is a terminal, and the `-f' or `--force' option is not given, mv prompts the user for whether to replace the file. (You might own the file, or have write permission on its directory.) If the response does not begin with `y' or `Y', the file is skipped.

Warning: If you try to move a symlink that points to a directory, and you specify the symlink with a trailing slash, then mv doesn't move the symlink but instead moves the directory referenced by the symlink. See section 2.4 Trailing slashes.

The program accepts the following options. Also see 2. Common options.

See section 2.1 Backup options. Make a backup of each file that would otherwise be overwritten or removed.

Do not prompt the user before removing a destination file.

Prompt whether to overwrite each existing destination file, regardless of its permissions. If the response does not begin with `y' or `Y', the file is skipped.

Specifying `--reply=yes' is equivalent to using `--force'. Specify `--reply=no' to make mv act as if `no' were given as a response to every prompt about a destination file. Specify `--reply=query' to make mv prompt the user about each existing destination file.

Do not move a non-directory that has an existing destination with the same or newer modification time.

Print the name of each file before moving it.

Remove any trailing slashes from each source argument. See section 2.4 Trailing slashes.

`-S suffix'
Append suffix to each backup file made with `-b'. See section 2.1 Backup options.

Specify the destination directory. See section 2.3 Target directory.

`-V method'
Change the type of backups made with `-b'. The method argument can be `none' (or `off'), `numbered' (or `t'), `existing' (or `nil'), or `never' (or `simple'). See section 2.1 Backup options.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003