CPIO(1-SysV) RISC/os Reference Manual CPIO(1-SysV)
NAME
cpio - copy file archives in and out
SYNOPSIS
cpio -o[acvVBHL] [-Cbsz] [-Mmsg] <name-list >out
cpio -o[acvVBHL] -Oout [-Cbsz] [-Mmsg] <name-list
cpio -i[bcdkmrsStuvVfB6HL] [-Cbsz] [-Mmsg] [pat ...]
cpio -i[bcdkmrsStuvVfB6HL] -Iin [-Cbsz] [-Mmsg] [pat ...]
cpio -p[adlmruvVHL] directory <name-list
DESCRIPTION
cpio -o (copy out) reads the standard input to obtain a list
of path names and copies those files onto the standard out-
put together with path name and status information. Output
is padded to a 512-byte boundary.
cpio -i (copy in) extracts files from the standard input,
which is assumed to be the product of a previous cpio -o.
Only files with names that match the pattern pat are
selected. pat is a regular expression given in the name-
generating notation of sh(1). In the pattern pat, meta-
characters ?, *, and [...] match the slash / character.
Multiple patterns may be specified and if no patterns are
specified, the default pattern is * (i.e., select all
files). Each pattern, should be surrounded by double
quotes. The extracted files are conditionally created and
copied into the current directory tree based upon the
options described below. The permissions of the files will
be those of the previous cpio -o. The owner and group of
the files will be that of the current user unless the user
is super-user, which causes cpio to retain the owner and
group of the files of the previous cpio -o. NOTE: If cpio
-i tries to create a file that already exists and the exist-
ing file is the same age or newer, cpio will output a warn-
ing message and not replace the file. (The -u option can be
used to unconditionally overwrite the existing file.)
cpio -p (pass) reads the standard input to obtain a list of
path names of files that are conditionally created and
copied into the destination directory tree based upon the
options described below.
The meanings of the available options are
-a Reset access times of input files after they have
been copied. Access times are not reset for linked
files when cpio -pla is specified.
-B Input/output is to be blocked into 5,120 byte
records.
-Cbsz Input/output is to be blocked into bsz byte records.
(The B and C options are meaningless when used with
the pass option and when data is not being directed
Printed 1/15/91 Page 1
CPIO(1-SysV) RISC/os Reference Manual CPIO(1-SysV)
to or from a character special device, e.g.
/dev/rmt/ctape0.)
-d Directories are to be created as needed.
-c Write header information in ASCII character form for
portability. Always use this option when origin and
destination machines are different types.
-r Interactively rename files. If the user types a
null line, the file is skipped. (Not available with
cpio -p.)
-t Print a table of contents of the input. No files
are created.
-u Copy unconditionally (normally, an older file will
not replace a newer file with the same name).
-v Verbose level 1: causes a list of file names to be
printed.
-V Verbose level 2: prints a dot for each file.
If both -v and -V are specified, the option occur-
ring latest in the argument list is the one that is
used. If either -v or -V is used with the t option,
the table of contents looks like the output of an
ls -l command (see ls(1)).
-l Whenever possible, link files rather than copying
them. Usable only with the -p option.
-m Retain previous file modification time. This option
is ineffective on directories that are being copied.
-f Copy in all files except those matching the pattern
pat.
-s swap bytes within each half word. Use only with the
-i option.
-S swap halfwords within each word. Use only with the
-i option.
-b Reverses the order of the bytes within each word.
Use only with the -i option.
-6 Process an old (i.e. UNIX System sixth Edition for-
mat) file. Only useful with -i (copy in).
-H Do not follow symbolic links (default). Symbolic
link records are saved in the archive to be
extracted on the other side. This is not portable
to all system types.
-L Follow symbolic links. Instead of archiving a
record for the symbolic link, a record for the tar-
get file is placed in the archive.
-Oout Specify the name of the output device. By specify-
ing the device this way instead of using redirec-
tion, the prompts for change of media use this as a
default.
-Iin Specify the name of the input device. By specifying
the device this way instead of using redirection,
the prompts for change of media use this as a
default.
Page 2 Printed 1/15/91
CPIO(1-SysV) RISC/os Reference Manual CPIO(1-SysV)
If cpio reaches end of medium (end of a tape for example),
when writing to (-o) or reading from (-i) a character spe-
cial device, cpio will print the message:
If you want to go on, type device/file name when ready.
To continue, you must replace the medium and type the char-
acter special device name (/dev/rmt/ctape0 for example) and
carriage return, unless the -I or -O option was used, in
which case you will be prompted with a default name, which
may be changed by typing a new one, accepted by typing
return, or you may abort the job by typing a 'q'. You may
want to continue by directing cpio to use a different dev-
ice. For example, if you have two floppy drives you may
want to switch between them so cpio can proceed while you
are changing the floppies. (A carriage return alone causes
the cpio process to exit.)
EXAMPLES
The following examples show three uses of cpio.
When standard input is directed through a pipe to cpio -o,
it groups the files so they can be directed (>) to a single
file (../newfile). Instead of ls, you could use find, echo,
cat, etc., to pipe a list of names to cpio. You could
direct the output to a device instead of a file.
ls | cpio -o > ../newfile
cpio -i uses the output file of cpio -o (directed through a
pipe with cat in the example), takes out those files that
match the patterns (memo/a1, memo/b*), creates directories
below the current directory as needed (-d option), and
places the files in the appropriate directories. If no pat-
terns were given, all files from newfile would be placed in
the directory.
cat newfile | cpio -id "memo/a1" "memo/b*"
cpio -p takes the file names piped to it and copies or links
(-l option) those files to another directory on your machine
(newdir in the example). The -d option says to create
directories as needed. The -m option says retain the modif-
ication time. (It is important to use the -depth option of
find to generate path names for cpio. This eliminates prob-
lems cpio could have trying to create files under read-only
directories. However, it will not work on empty direc-
tories.)
find . -depth -print | cpio -pdlmv newdir
Printed 1/15/91 Page 3
CPIO(1-SysV) RISC/os Reference Manual CPIO(1-SysV)
SEE ALSO
ar(1), find(1), ls(1),
cpio(4) in the Programmer's Reference Manual.
NOTES
1) cpio assumes four-byte words.
2) Only the super-user can copy special files.
3) Blocks are reported in 512-byte quantities.
4) The device/inode pair appearing in the headers is created
by cpio as one 32-bit number, and has no correlation to
the real device/inode numbers of the file. The cpio
number begins with the number 3 and increments sequen-
tially for each file processed by cpio.
Page 4 Printed 1/15/91