m

mv(1)

mv(1)

If new-®leis a new ®le, it inherits the access control list of ®le1, altered to re¯ect any difference in ownership between the two ®les (see acl(5) and aclv(5)). In JFS ®le systems, new ®les created by mv do not inherit their parent directory's default ACL entries (if any), but instead retain their original ACLs. When moving ®les from a JFS ®le system to an HFS ®le system or vice versa, optional ACL entries are lost.

EXTERNAL INFLUENCES

Environment Variables

LC_CTYPE determines the interpretation of text as single byte and/or multibyte characters.

LANG and LC_CTYPE determine the local language equivalent of y (for yes/no queries).

LANG determines the language in which messages are displayed.

If LC_CTYPE is not speci®ed in the environment or is set to the empty string, the value of LANG is used as a default for each unspeci®ed or empty variable. If LANG is not speci®ed or is set to the empty string, a default of C (see lang(5)) is used instead of LANG. If any internationalization variable contains an invalid setting, mv behaves as if all internationalization variables are set to C. See environ(5).

International Code Set Support

Single character and multibyte character code sets are supported.

EXAMPLES

Rename a ®le in the current directory:

mv old-filename new-filename

Rename a directory in the current directory:

mv old-dirname new-dirname

Rename a ®le in the current directory whose name starts with a nonprinting control character or a character that is special to the shell, such as - and * (extra care may be required depending on the situation):

mv ./bad-filename new-filename mv ./?bad-filename new-filename mv ./*bad-filename new-filename

Move directory sourcedir and its contents to a new location (targetdir) in the ®le system (upon completion, a subdirectory named sourcedir resides in directory targetdir):

mv sourcedir targetdir

Move all ®les and directories (including links) in the current directory to a new location underneath tar- getdir:

mv * targetdir

Move all ®les and directories (including links) in sourcedir to a new location underneath targetdir (sourcedir and targetdir are in separate directory paths):

mv sourcedir/* targetdir

WARNINGS

If ®le1 and new-®leexist on different ®le systems, mv copies the ®le and deletes the original. In this case the mover becomes the owner and any linking relationship with other ®les is lost. mv cannot carry hard links across ®le systems. If ®le1 is a directory, mv copies the entire directory structure onto the destination ®le system and deletes the original.

mv cannot be used to perform the following operations:

Rename either the current working directory or its parent directory using the . or .. notation.

Rename a directory to a new name identical to the name of a ®le contained in the same parent directory.

DEPENDENCIES

NFS

Access control lists of networked ®les are summarized (as returned in st_mode by stat(2)), but not copied to the new ®le. When using mv on such ®les, a + is not printed after the mode value when asking for permission to overwrite a ®le.

Section 1554

− 2 −

HP-UX Release 11i: December 2000