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