xref: /original-bsd/old/cpio/cpio.1 (revision 9d44d164)
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)cpio.1	5.5 (Berkeley) 07/24/90
7.\"
8.\"	@(#)cpio.1	5.3 (Berkeley) 3/29/88
9.\"
10.Dd
11.Dt CPIO 1
12.Os BSD 4.4
13.Sh NAME
14.Nm cpio
15.Nd copy file archives in and out
16.Sh SYNOPSIS
17.Nm cpio
18.Fl o
19.Op Fl acBv
20.br
21.Nm cpio
22.Fl i
23.Op Fl BcdmrtuvfsSb6
24.Op Ar patterns
25.br
26.Nm cpio
27.Fl p
28.Op Fl adlmruv
29.Ar directory
30.Sh DESCRIPTION
31.Nm Cpio
32has three functional modes; copy out, copy in and pass.
33.Pp
34Functional Options:
35.Tw Ds
36.Tp Fl o
37Copy out \- reads the standard input to obtain a list
38of path names and copies those files onto the standard
39output together with path name and status information.
40Output is padded to a 512-byte boundary.
41.Pp
42.Tp Fl i
43Copy in \- extracts files from the standard input,
44which is assumed to be the product of a previous
45.Nm cpio
46.Fl o .
47Only files with names that match patterns are selected.
48Patterns are given in the name-generating notation of
49.Xr sh 1 .
50In patterns, meta-characters
51.Sq Li \&? ,
52.Sq Li \&* ,
53and
54.Sq Li [...]
55match the
56slash
57.Sq Li \&/
58character.  Multiple patterns may be specified and
59if no patterns are specified, the default for patterns is
60.Sq Li \&*
61(i.e., select all files).  The extracted files are
62conditionally created and copied into the current directory
63tree based upon the options described below.  The
64permissions of the files will be those of the previous
65.Nm cpio
66.Fl o .
67The owner and group of the files will be that of the
68current user unless the user is super-user, which causes
69.Nm cpio
70to retain the owner and group of the files of the
71previous
72.Nm cpio
73.Fl o .
74.Pp
75.Tp Fl p
76Pass \- reads the standard input to obtain a list of
77path names of files that are conditionally created and
78copied into the destination directory tree based upon the
79options described below.
80.Tp
81.Pp
82Options for the above functional options:
83.Tw Ds
84.Tp Fl a
85Reset access times of input files after they have been
86copied.
87.Tp Fl B
88Input/output is to be blocked 5,120 bytes to the record
89(does not apply to the pass options; meaningful only
90with data directed to or from
91.Pa /dev/rmt/??).
92.Tp Fl d
93Directories are to be created as needed.
94.Tp Fl c
95Write header information in ASCII character form for
96portability.
97.Tp Fl r
98Interactively rename files.  If the user types a null
99line, the files is skipped.
100.Tp Fl t
101Print a table of contents of the input.  No files are
102created.
103.Tp Fl u
104Copy unconditionally (normally, an older file will not
105replace a newer file with the same name).
106.Tp Fl v
107Verbose: causes a list of file names to be printed.
108When used with the t option, the table of contents
109looks like the output of an
110.Ql ls -l
111command (see
112.Xr ls 1 ) .
113.Tp Fl l
114Whenever possible, link files rather than copying them.
115Usable only with the
116.Fl p
117option.
118.Tp Fl m
119Retain previous file modification time.  This option is
120ineffective on directories that are being copied.
121.Tp Fl f
122Copy in all files except those in patterns.
123.Tp Fl s
124Swap bytes.  Use only with the
125.Fl i
126option.
127.Tp Fl S
128Swap halfwords.  Use only with the
129.Fl i
130option.
131.Tp Fl b
132halfwords.  Use only with the
133.Fl i
134option.
135.Tp Fl 6
136Process an old (i.e., UNIX System Sixth Edition format)
137file.  Only useful with
138.Fl i
139(copy in).
140.Tp
141.Sh EXAMPLES
142The first example below copies the contents of a directory
143into an archive; the second duplicates a directory
144hierarchy:
145.Pp
146.Dl ls  \&| cpio -o >/dev/rmt/0m
147.Pp
148.Dl cd olddir
149.Dl find . -depth -print \&|  cpio -pdl newdir
150.Pp
151The trivial case
152.Pp
153.Dl find . -depth -print \&|  cpio -oB >/dev/fmt/0m
154.Pp
155can be handled more efficiently by:
156.Pp
157.Dl find . -cpio /dev/rmt/0m
158.Pp
159.Sh SEE ALSO
160.Xr ar 1 ,
161.Xr find 1 ,
162.Xr ls 1 ,
163.Xr cpio 4
164.Sh HISTORY
165The
166.Nm cpio
167command appeared in System V AT&T UNIX.  This program is derived
168from the System V AT&T sources which were contributed to the public
169domain by AT&T.
170.Sh BUGS
171Path names are restricted to 128 characters.  If there are
172too many unique linked files, the program runs out of memory
173to keep track of them and, thereafter, linking information
174is lost.  Only the super-user can copy special files.  The
175.Fl B
176option does not work with certain magnetic tape drives.
177