1mv(1)                            User Commands                           mv(1)
2
3
4

NAME

6       mv - move files
7

SYNOPSIS

9       /usr/bin/mv [-fi] source target_file
10
11
12       /usr/bin/mv [-fi] source... target_dir
13
14
15       /usr/xpg4/bin/mv [-fi] source target_file
16
17
18       /usr/xpg4/bin/mv [-fi] source... target_dir
19
20

DESCRIPTION

22       In  the first synopsis form, the mv utility moves the file named by the
23       source operand to the destination specified by the target_file.  source
24       and  target_file  can  not  have the same name. If target_file does not
25       exist, mv creates a file named target_file. If target_file exists,  its
26       contents  are overwritten. This first synopsis form is assumed when the
27       final operand does not name an existing directory.
28
29
30       In the second synopsis form, mv moves each file named by a source oper‐
31       and  to  a destination file in the existing directory named by the tar‐
32       get_dir operand. The destination path for each source is the concatena‐
33       tion  of  the  target  directory, a single slash character (/), and the
34       last path name component of the source. This  second  form  is  assumed
35       when the final operand names an existing directory.
36
37
38       If  mv  determines  that  the  mode  of target_file forbids writing, it
39       prints the mode (see chmod(2)), ask for a response, and read the  stan‐
40       dard input for one line. If the response is affirmative, the mv occurs,
41       if permissible; otherwise, the command exits. Notice that the mode dis‐
42       played can not fully represent the access permission if target is asso‐
43       ciated with an ACL. When the parent directory of source is writable and
44       has the sticky bit set, one or more of the following conditions must be
45       true:
46
47           o      the user must own the file
48
49           o      the user must own the directory
50
51           o      the file must be writable by the user
52
53           o      the user must be a privileged user
54
55
56       If source is a file and target_file is a  link  to  another  file  with
57       links, the other links remain and target_file becomes a new file.
58
59
60       If  source and target_file/target_dir are on different file systems, mv
61       copies the source and deletes the original. Any  hard  links  to  other
62       files  are  lost. mv attempts to duplicate the source file characteris‐
63       tics to the target, that is, the owner and group id, permission  modes,
64       modification and access times, ACLs, and extended attributes, if appli‐
65       cable. For symbolic links, mv preserves only the owner and group of the
66       link itself.
67
68
69       If unable to preserve owner and group id, mv clears S_ISUID and S_ISGID
70       bits in the target. mv prints a diagnostic message to stderr if  unable
71       to  clear these bits, though the exit code is not affected. mv might be
72       unable to preserve extended attributes if the target file  system  does
73       not have extended attribute support. /usr/xpg4/bin/mv prints a diagnos‐
74       tic message to stderr for all other failed attempts to  duplicate  file
75       characteristics. The exit code is not affected.
76
77
78       In  order  to preserve the source file characteristics, users must have
79       the appropriate file access permissions. This includes being super-user
80       or having the same owner id as the destination file.
81

OPTIONS

83       The following options are supported:
84
85       -f    mv moves the file(s) without prompting even if it is writing over
86             an existing target. Note that this is the default if the standard
87             input is not a terminal.
88
89
90       -i    mv  prompts for confirmation whenever the move would overwrite an
91             existing target. An affirmative answer means that the move should
92             proceed.  Any  other answer prevents mv from overwriting the tar‐
93             get.
94
95
96   /usr/bin/mv
97       Specifying both the -f and the -i options is not considered  an  error.
98       The -f option overrides the -i option.
99
100   /usr/xpg4/bin/mv
101       Specifying  both  the -f and the -i options is not considered an error.
102       The last option specified determines the behavior of mv.
103

OPERANDS

105       The following operands are supported:
106
107       source         A path name of a file or directory to be moved.
108
109
110       target_file    A new path name for the file or directory being moved.
111
112
113       target_dir     A path name of an existing directory into which to  move
114                      the input files.
115
116

USAGE

118       See largefile(5) for the description of the behavior of mv when encoun‐
119       tering files greater than or equal to 2 Gbyte ( 2^31 bytes).
120

ENVIRONMENT VARIABLES

122       See environ(5) for descriptions of the following environment  variables
123       that  affect  the  execution of mv: LANG, LC_ALL, LC_COLLATE, LC_CTYPE,
124       LC_MESSAGES, and NLSPATH.
125
126
127       Affirmative responses are processed using the extended regular  expres‐
128       sion defined for the yesexpr keyword in the LC_MESSAGES category of the
129       user's locale. The locale specified in the LC_COLLATE category  defines
130       the  behavior  of ranges, equivalence classes, and multi-character col‐
131       lating elements used in the expression defined for yesexpr. The  locale
132       specified  in  LC_CTYPE  determines  the  locale  for interpretation of
133       sequences of bytes of text data a characters, the behavior of character
134       classes used in the expression defined for the yesexpr. See locale(5).
135

EXIT STATUS

137       The following exit values are returned:
138
139       0     All input files were moved successfully.
140
141
142       >0    An error occurred.
143
144

ATTRIBUTES

146       See attributes(5) for descriptions of the following attributes:
147
148   /usr/bin/mv
149       ┌─────────────────────────────┬─────────────────────────────┐
150       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
151       ├─────────────────────────────┼─────────────────────────────┤
152       │Availability                 │SUNWcsu                      │
153       ├─────────────────────────────┼─────────────────────────────┤
154       │CSI                          │Enabled                      │
155       ├─────────────────────────────┼─────────────────────────────┤
156       │Interface Stability          │Stable                       │
157       └─────────────────────────────┴─────────────────────────────┘
158
159   /usr/xpg4/bin/mv
160       ┌─────────────────────────────┬─────────────────────────────┐
161       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
162       ├─────────────────────────────┼─────────────────────────────┤
163       │Availability                 │SUNWxcu4                     │
164       ├─────────────────────────────┼─────────────────────────────┤
165       │CSI                          │Enabled                      │
166       ├─────────────────────────────┼─────────────────────────────┤
167       │Interface Stability          │Standard                     │
168       └─────────────────────────────┴─────────────────────────────┘
169

SEE ALSO

171       cp(1), cpio(1), ln(1), rm(1), setfacl(1), chmod(2), attributes(5), env‐
172       iron(5), fsattr(5), largefile(5), standards(5)
173

NOTES

175       A -- permits the user to mark explicitly the end of  any  command  line
176       options,  allowing mv to recognize filename arguments that begin with a
177       -. As an aid to BSD migration, mv accepts - as a synonym for  --.  This
178       migration aid might disappear in a future release.
179
180
181
182SunOS 5.11                        17 Jul 2007                            mv(1)
Impressum