1CP(1) User Commands CP(1)
2
3
4
6 cp - copy files and directories
7
9 cp [OPTION]... [-T] SOURCE DEST
10 cp [OPTION]... SOURCE... DIRECTORY
11 cp [OPTION]... -t DIRECTORY SOURCE...
12
14 Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
15
16 Mandatory arguments to long options are mandatory for short options
17 too.
18
19 -a, --archive
20 same as -dpPR
21
22 --backup[=CONTROL]
23 make a backup of each existing destination file
24
25 -b like --backup but does not accept an argument
26
27 --copy-contents
28 copy contents of special files when recursive
29
30 -d same as --no-dereference --preserve=link
31
32 -f, --force
33 if an existing destination file cannot be opened, remove it and
34 try again
35
36 -i, --interactive
37 prompt before overwrite
38
39 -H follow command-line symbolic links
40
41 -l, --link
42 link files instead of copying
43
44 -L, --dereference
45 always follow symbolic links
46
47 -P, --no-dereference
48 never follow symbolic links
49
50 -p same as --preserve=mode,ownership,timestamps
51
52 --preserve[=ATTR_LIST]
53 preserve the specified attributes (default: mode,ownership,time‐
54 stamps) and security contexts, if possible additional
55 attributes: links, all
56
57 --no-preserve=ATTR_LIST
58 don't preserve the specified attributes
59
60 --parents
61 use full source file name under DIRECTORY
62
63 -R, -r, --recursive
64 copy directories recursively
65
66 --remove-destination
67 remove each existing destination file before attempting to open
68 it (contrast with --force)
69
70 --sparse=WHEN
71 control creation of sparse files
72
73 --strip-trailing-slashes
74 remove any trailing slashes from each SOURCE argument
75
76 -s, --symbolic-link
77 make symbolic links instead of copying
78
79 -S, --suffix=SUFFIX
80 override the usual backup suffix
81
82 -t, --target-directory=DIRECTORY
83 copy all SOURCE arguments into DIRECTORY
84
85 -T, --no-target-directory
86 treat DEST as a normal file
87
88 -u, --update
89 copy only when the SOURCE file is newer than the destination
90 file or when the destination file is missing
91
92 -v, --verbose
93 explain what is being done
94
95 -x, --one-file-system
96 stay on this file system
97
98 --help display this help and exit
99
100 -Z, --context=CONTEXT
101 set security context of copy to CONTEXT
102
103 --version
104 output version information and exit
105
106 By default, sparse SOURCE files are detected by a crude heuristic and
107 the corresponding DEST file is made sparse as well. That is the behav‐
108 ior selected by --sparse=auto. Specify --sparse=always to create a
109 sparse DEST file whenever the SOURCE file contains a long enough
110 sequence of zero bytes. Use --sparse=never to inhibit creation of
111 sparse files.
112
113 The backup suffix is `~', unless set with --suffix or SIM‐
114 PLE_BACKUP_SUFFIX. The version control method may be selected via the
115 --backup option or through the VERSION_CONTROL environment variable.
116 Here are the values:
117
118 none, off
119 never make backups (even if --backup is given)
120
121 numbered, t
122 make numbered backups
123
124 existing, nil
125 numbered if numbered backups exist, simple otherwise
126
127 simple, never
128 always make simple backups
129
130 As a special case, cp makes a backup of SOURCE when the force and
131 backup options are given and SOURCE and DEST are the same name for an
132 existing, regular file.
133
135 Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
136
138 Report bugs to <bug-coreutils@gnu.org>.
139
141 Copyright © 2007 Free Software Foundation, Inc.
142 This is free software. You may redistribute copies of it under the
143 terms of the GNU General Public License
144 <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the
145 extent permitted by law.
146
148 The full documentation for cp is maintained as a Texinfo manual. If
149 the info and cp programs are properly installed at your site, the com‐
150 mand
151
152 info cp
153
154 should give you access to the complete manual.
155
156
157
158GNU coreutils 6.9 March 2007 CP(1)