1 .\" Copyright (c) 2003-2007 Tim Kientzle
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .Nd copy files to and from archives
51 copies files between archives and directories.
52 This implementation can extract from tar, pax, cpio, zip, jar, ar,
53 and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
58 is a mode indicator from the following list:
59 .Bl -tag -compact -width indent
62 Read an archive from standard input (unless overriden) and extract the
63 contents to disk or (if the
66 list the contents to standard output.
67 If one or more file patterns are specified, only files matching
68 one of the patterns will be extracted.
71 Read a list of filenames from standard input and produce a new archive
72 on standard output (unless overriden) containing the specified items.
75 Read a list of filenames from standard input and copy the files to the
80 Unless specifically stated otherwise, options are applicable in
82 .Bl -tag -width indent
85 Append to the specified archive.
86 (Not yet implemented.)
89 Reset access times on files after they are read.
92 Block output to records of 5120 bytes.
95 Block output to records of
100 Use the old POSIX portable character format.
105 Create directories as necessary.
108 Read list of file name patterns from
112 Read archive from or write archive to
116 Ignore files that match
118 .It Fl -format Ar format
120 Produce the output archive in the specified format.
121 Supported formats include:
123 .Bl -tag -width "iso9660" -compact
128 The SVR4 portable cpio format.
130 The old POSIX.1 portable octet-oriented cpio format.
132 The POSIX.1 pax format, an extension of the ustar format.
134 The POSIX.1 tar format.
137 The default format is
140 .Xr libarchive_formats 5
141 for more complete information about the
142 formats currently supported by the underlying
150 See above for description.
153 Disable security checks during extraction or copying.
154 This allows extraction via symbolic links and path names containing
159 All symbolic links will be followed.
160 Normally, symbolic links are archived and copied as symbolic links.
161 With this option, the target of the link will be archived or copied instead.
164 Create links from the target directory to the original files,
168 Set file modification time on created files to match
173 Display numeric uid and gid.
176 displays the user and group names when they are provided in the
177 archive, or looks up the user and group names in the system
184 See above for description.
187 See above for description.
189 Suppress unnecessary messages.
190 .It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc
191 Set the owner and/or group on files in the output.
192 If group is specified with no user
195 then the group will be set but not the user.
196 If the user is specified with a trailing colon and no group
199 then the group will be set to the user's default group.
200 If the user is specified with no trailing colon, then
201 the user will be set but not the group.
206 modes, this option can only be used by the super-user.
207 (For compatibility, a period can be used in place of the colon.)
210 Rename files interactively.
211 For each file, a prompt is written to
213 containing the name of the file and a line is read from
215 If the line read is blank, the file is skipped.
216 If the line contains a single period, the file is processed normally.
217 Otherwise, the line is taken to be the new name of the file.
220 List the contents of the archive to stdout;
221 do not restore the contents to disk.
224 Unconditionally overwrite existing files.
225 Ordinarily, an older file will not overwrite a newer file on disk.
227 Print the name of each file to stderr as it is processed.
230 provide a detailed listing of each file.
232 Print the program version information and exit.
235 Compress the archive with bzip2-compatible compression before writing it.
236 In input mode, this option is ignored;
237 bzip2 compression is recognized automatically on input.
240 Compress the archive with compress-compatible compression before writing it.
241 In input mode, this option is ignored;
242 compression is recognized automatically on input.
245 Compress the archive with gzip-compatible compression before writing it.
246 In input mode, this option is ignored;
247 gzip compression is recognized automatically on input.
250 The following environment variables affect the execution of
252 .Bl -tag -width ".Ev BLOCKSIZE"
257 for more information.
259 The timezone to use when displaying dates.
262 for more information.
269 command is traditionally used to copy file heirarchies in conjunction
273 The first example here simply copies all files from
277 .Dl Nm find Pa src | Nm Fl pmud Pa dest
279 By carefully selecting options to the
281 command and combining it with other standard utilities,
282 it is possible to exercise very fine control over which files are copied.
283 This next example copies files from
287 that are more than 2 days old and whose names match a particular pattern:
288 .Dl Nm find Pa src Fl mtime Ar +2 | Nm grep foo[bar] | Nm Fl pdmu Pa dest
290 This example copies files from
294 that are more than 2 days old and which contain the word
296 .Dl Nm find Pa src Fl mtime Ar +2 | Nm xargs Nm grep -l foobar | Nm Fl pdmu Pa dest
298 The mode options i, o, and p and the options
299 a, B, c, d, f, l, m, r, t, u, and v comply with SUSv2.
301 The old POSIX.1 standard specified that only
306 were interpreted as command-line options.
307 Each took a single argument of a list of modifier
309 For example, the standard syntax allows
319 are only modifiers to
321 they are not command-line options in their own right.
322 The syntax supported by this implementation is backwards-compatible
324 For best compatibility, scripts should limit themselves to the
334 .Xr libarchive-formats 5 ,
337 There is no current POSIX standard for the cpio command; it appeared
343 The cpio, ustar, and pax interchange file formats are defined by
351 utilities were written by Dick Haight
352 while working in AT&T's Unix Support Group.
353 They first appeared in 1977 in PWB/UNIX 1.0, the
354 .Dq Programmer's Work Bench
355 system developed for use within AT&T.
356 They were first released outside of AT&T as part of System III Unix in 1981.
361 even though it was not well-known outside of AT&T until some time later.
363 This is a complete re-implementation based on the
367 The cpio archive format has several basic limitations:
368 It does not store user and group names, only numbers.
369 As a result, it cannot be reliably used to transfer
370 files between systems with dissimilar user and group numbering.
371 Older cpio formats limit the user and group numbers to
372 16 or 18 bits, which is insufficient for modern systems.
373 The cpio archive formats cannot support files over 4 gigabytes,
376 variant, which can support files up to 8 gigabytes.