[9] | 1 | .TH CP 1
|
---|
| 2 | .SH NAME
|
---|
| 3 | cp, mv, rm, ln, cpdir, clone \- copy, move, remove, link
|
---|
| 4 | .SH SYNOPSIS
|
---|
| 5 | .B cp
|
---|
| 6 | .RB [ \-pifsmrRvx ]
|
---|
| 7 | .I file1 file2
|
---|
| 8 | .br
|
---|
| 9 | .B cp
|
---|
| 10 | .RB [ \-pifsrRvx ]
|
---|
| 11 | .IR file " ... " dir
|
---|
| 12 | .PP
|
---|
| 13 | .B mv
|
---|
| 14 | .RB [ \-ifsmvx ]
|
---|
| 15 | .I file1 file2
|
---|
| 16 | .br
|
---|
| 17 | .B mv
|
---|
| 18 | .RB [ \-ifsvx ]
|
---|
| 19 | .IR file " ... " dir
|
---|
| 20 | .PP
|
---|
| 21 | .B rm
|
---|
| 22 | .RB [ \-ifrRvx ]
|
---|
| 23 | .IR file " ..."
|
---|
| 24 | .PP
|
---|
| 25 | .B ln
|
---|
| 26 | .RB [ \-ifsSmrRvx ]
|
---|
| 27 | .I file1 file2
|
---|
| 28 | .br
|
---|
| 29 | .B ln
|
---|
| 30 | .RB [ \-ifsSrRvx ]
|
---|
| 31 | .IR file " ... " dir
|
---|
| 32 | .PP
|
---|
| 33 | .B cpdir
|
---|
| 34 | .RB [ \-ifvx ]
|
---|
| 35 | .I file1 file2
|
---|
| 36 | .PP
|
---|
| 37 | .B clone
|
---|
| 38 | .RB [ \-ifsSvx ]
|
---|
| 39 | .I file1 file2
|
---|
| 40 | .SH DESCRIPTION
|
---|
| 41 | .de SP
|
---|
| 42 | .if t .sp 0.4
|
---|
| 43 | .if n .sp
|
---|
| 44 | ..
|
---|
| 45 | The utilities
|
---|
| 46 | .BR cp ,
|
---|
| 47 | .BR mv ,
|
---|
| 48 | .BR rm ,
|
---|
| 49 | and
|
---|
| 50 | .B ln
|
---|
| 51 | do basic file management: copying, renaming or moving, deletion, and
|
---|
| 52 | creating links. (The
|
---|
| 53 | .B cpdir
|
---|
| 54 | and
|
---|
| 55 | .B clone
|
---|
| 56 | utilities are easy to use aliases for copying or linking whole trees.
|
---|
| 57 | They are the same as
|
---|
| 58 | .B cp \-psmr
|
---|
| 59 | and
|
---|
| 60 | .BR "ln \-fmr" )
|
---|
| 61 | .PP
|
---|
| 62 | The first synopsis form of the utilities
|
---|
| 63 | .BR cp ,
|
---|
| 64 | .BR mv ,
|
---|
| 65 | and
|
---|
| 66 | .B ln
|
---|
| 67 | is used if only two arguments are given, and the second argument is not a
|
---|
| 68 | directory. The source and target file are then the two files given.
|
---|
| 69 | .PP
|
---|
| 70 | If the second synopsis form is used then the last argument must be a
|
---|
| 71 | directory. Each of the files is copied, moved or linked into this directory.
|
---|
| 72 | .PP
|
---|
| 73 | A file is by default copied by
|
---|
| 74 | .B cp
|
---|
| 75 | without looking at its type, so symlinks are followed and devices are opened
|
---|
| 76 | and read from or written to. Links between files are ignored. This
|
---|
| 77 | behavior can be changed by using the proper options.
|
---|
| 78 | .PP
|
---|
| 79 | The
|
---|
| 80 | .B mv
|
---|
| 81 | utility uses the
|
---|
| 82 | .BR rename (2)
|
---|
| 83 | call to rename or move files. If source and target are on different devices
|
---|
| 84 | however, then
|
---|
| 85 | .B mv
|
---|
| 86 | will use
|
---|
| 87 | .B cp \-pr
|
---|
| 88 | to copy the files or directory trees.
|
---|
| 89 | .PP
|
---|
| 90 | Each utility continues with the next file on errors, except on I/O errors.
|
---|
| 91 | .SH OPTIONS
|
---|
| 92 | .TP
|
---|
| 93 | .B \-p
|
---|
| 94 | Copy the file attributes like mode, owner, group and time of last
|
---|
| 95 | modification. Normally only the mode is copied to a new file with the file
|
---|
| 96 | creation mask applied. Setuid bits are cleared if setting the ownership
|
---|
| 97 | fails.
|
---|
| 98 | .TP
|
---|
| 99 | .B \-i
|
---|
| 100 | Ask if ok to overwrite, replace or remove.
|
---|
| 101 | .B Mv
|
---|
| 102 | and
|
---|
| 103 | .B rm
|
---|
| 104 | will ask this automatically if interactive and the target file is writable.
|
---|
| 105 | .B Cp
|
---|
| 106 | will fail if the target cannot be written,
|
---|
| 107 | .B ln
|
---|
| 108 | will always fail if the target exists.
|
---|
| 109 | .TP
|
---|
| 110 | .B \-f
|
---|
| 111 | Makes
|
---|
| 112 | .B cp
|
---|
| 113 | remove a target file before copying if it is not writable,
|
---|
| 114 | .B mv
|
---|
| 115 | removes an existing target without asking,
|
---|
| 116 | .B rm
|
---|
| 117 | does not report any errors, and
|
---|
| 118 | .B ln
|
---|
| 119 | removes an existing target file before linking. The last of
|
---|
| 120 | .B \-i
|
---|
| 121 | and
|
---|
| 122 | .B \-f
|
---|
| 123 | wins for
|
---|
| 124 | .B mv
|
---|
| 125 | if both flags are set, the other utilities do something sensible, like asking
|
---|
| 126 | before forcefully removing.
|
---|
| 127 | .TP
|
---|
| 128 | .B \-s
|
---|
| 129 | Make a symlink instead of a normal link. For utilities other than
|
---|
| 130 | .B ln
|
---|
| 131 | this flag means "copy similar". The modified time is always copied for
|
---|
| 132 | .B cp \-s
|
---|
| 133 | and the other attributes are copied if a new file is created. The normal
|
---|
| 134 | \s-2POSIX\s+2 required patronizing like applying the file creation mask or
|
---|
| 135 | clearing setuid bits is not done.
|
---|
| 136 | .TP
|
---|
| 137 | .B \-S
|
---|
| 138 | Make a symlink if a normal link cannot be made because source and target are
|
---|
| 139 | on different devices. The symlink is required to really refer back to the
|
---|
| 140 | source, meaning that a/b must exist in the call
|
---|
| 141 | .BR "ln \-S a/b c/d" ,
|
---|
| 142 | and that the symlink from c/d must lead back to a/b. So the symlink will be
|
---|
| 143 | created as if
|
---|
| 144 | .B "ln \-s ../a/b c/d"
|
---|
| 145 | was called. If the target is a full path, but the source is not then an
|
---|
| 146 | error will be given saying that this is "too difficult."
|
---|
| 147 | .TP
|
---|
| 148 | .B \-m
|
---|
| 149 | Merge trees. The first synopsis form is assumed, and the files from one
|
---|
| 150 | tree are merged into the other. There is no "if it's a directory the put
|
---|
| 151 | it into that directory" trickery here.
|
---|
| 152 | .TP
|
---|
| 153 | .BR \-r ", " \-R
|
---|
| 154 | Recursively copy, remove, or link. If the source is a directory then the
|
---|
| 155 | files in this directory are copied to similarly named files in the target
|
---|
| 156 | directory. Special files are copied as new special files, they are not read
|
---|
| 157 | or written. Symlinks are still expanded and the link structure ignored with
|
---|
| 158 | .BR \-R .
|
---|
| 159 | The
|
---|
| 160 | .B \-r
|
---|
| 161 | flag does copy symlinks as symlinks and keeps the link structure intact.
|
---|
| 162 | (Note that
|
---|
| 163 | .B \-R
|
---|
| 164 | is invented by \s-2POSIX\s+2 as a replacement for the classic
|
---|
| 165 | .B \-r
|
---|
| 166 | option of older copy commands that did read special files. The standard
|
---|
| 167 | says that
|
---|
| 168 | .B \-r
|
---|
| 169 | is implementation defined, so that's why this flag is better than
|
---|
| 170 | .B \-R
|
---|
| 171 | in this implementation of
|
---|
| 172 | .BR cp .)
|
---|
| 173 | For
|
---|
| 174 | .B rm
|
---|
| 175 | and
|
---|
| 176 | .B ln
|
---|
| 177 | both flags mean the same.
|
---|
| 178 | .B Ln
|
---|
| 179 | will recursively link the files in the trees, except symlinks, they are
|
---|
| 180 | copied. If symlinks are created with
|
---|
| 181 | .B ln \-rs
|
---|
| 182 | or
|
---|
| 183 | .B ln \-rS
|
---|
| 184 | then they are required "to work" as described with the
|
---|
| 185 | .B \-S
|
---|
| 186 | flag.
|
---|
| 187 | .TP
|
---|
| 188 | .B \-v
|
---|
| 189 | Verbose. Show what is done on standard output.
|
---|
| 190 | .TP
|
---|
| 191 | .B \-x
|
---|
| 192 | Do not cross mount points. Empty directories will be created if the source
|
---|
| 193 | directory is a mount point on a copy, move or link. A mount point will not
|
---|
| 194 | be removed or traversed recursively. This flag allows one to copy the root
|
---|
| 195 | device, e.g.
|
---|
| 196 | .BR "cpdir \-x / /mnt" .
|
---|
| 197 | .SH "SEE ALSO"
|
---|
| 198 | .BR cat (1),
|
---|
| 199 | .BR mkdir (1),
|
---|
| 200 | .BR rmdir (1),
|
---|
| 201 | .BR mkdir (2),
|
---|
| 202 | .BR rmdir (2),
|
---|
| 203 | .BR link (2),
|
---|
| 204 | .BR unlink (2),
|
---|
| 205 | .BR rename (2),
|
---|
| 206 | .BR open (2),
|
---|
| 207 | .BR read (2),
|
---|
| 208 | .BR write (2),
|
---|
| 209 | .BR opendir (3).
|
---|
| 210 | .SH NOTES
|
---|
| 211 | All the utilities described are links to the same program.
|
---|
| 212 | .SH BUGS
|
---|
| 213 | .B Mv
|
---|
| 214 | should first copy a tree across devices and then remove the source tree if
|
---|
| 215 | there was no error. Instead, each file in the tree is copied and
|
---|
| 216 | immediately removed. On error you may be left with two half-filled trees,
|
---|
| 217 | together containing all of the files. You may have to restart the move with
|
---|
| 218 | .BR "mv \-m" .
|
---|
| 219 | .PP
|
---|
| 220 | .B Rm
|
---|
| 221 | should be able to remove arbitrarily deep trees.
|
---|
| 222 | .SH AUTHOR
|
---|
| 223 | Kees J. Bot (kjb@cs.vu.nl)
|
---|