cpioarchiver to copy and back up files |
Command |
cpio
-o
[-aBcHhNvyz
]
[-C
blocksize]
[-O
file]
[-V
volpat]
cpio
-i
[-BbcdfHhmNrsStuvqy
]
[-C
blocksize]
[-I
file]
[-V
volpat]
[pattern ...]
cpio
-p
[-aBdlNmruv
]
directory
cpio
command manipulates files called
cpio
archives. A cpio
archive is a
concatenation of files and directories preceded by a header that gives the file
name and other file system information. With cpio
, you can
create a new archive, extract the contents of an existing archive, list archive
contents, and copy files from one directory to another.
cpio
. Every call to cpio
must specify one and only one of the following primary options:
-i
reads an existing archive (created with the -o
option) from the standard input. Unless you specify the
-t
option, cpio
-i
extracts all files matching one or more of the
given pattern arguments from the archive. Patterns are the same as
those used by file name generation (see
sh
). When you do not specify a
pattern argument, the default pattern *
is used; as a
result, cpio
extracts all files.
-o
writes a new archive to the standard output, using the list of files
read from the standard input. Such a list might be produced by the
ls
or
find
commands. For example,
usesls . | cpio -o >arch
ls
to list the files of the
current directory, then pipes this list as input to
cpio
. The resulting archive contains the contents of
all the files, and is written to arch
.-p
copies the list of files read from standard input to the specified directory. You can use this option to copy entire file trees.
-a
resets the access time of each file that is accessed for copying to what it was before the copy took place.
-B
uses buffers of 5120 bytes for input and output rather than the default 512 byte buffers.
-b
causes 16-bit words to be swapped within each long word and bytes to be
swapped within each 16-bit word of each extracted file. This facilitates
the transfer of information between different CPU architectures. This is
equivalent to specifying both the -s
and
-S
options.
-C
blocksizesets the buffer size to a specified blocksize, rather than the default 512 byte buffers.
-c
reads and writes header information in ASCII form. Normally,
cpio
writes the header information in a compact binary
format. This option produces an archive more amenable to transfer through
non-binary streams (such as some data communications links) and is highly
recommended for moving data between different processors, such as between
a UNIX system and a PC.
-d
forces the creation of necessary intermediate directories if they do not already exist.
-f
inverts the sense of pattern matching. More precisely,
cpio
extracts a file from the archive if and only if
it does not match any of the pattern arguments.
-H
creates and reads cpio
archives that contain
extraneous header characters, for compatibility with historical versions
of cpio
.
-h
creates and reads cpio
archives with headers
structured in a "little-endian" pattern. The term "little-endian" refers
to the internal ordering of bytes representing numbers, stipulating that
the least significant values come first. This is the common standard for
PCs, but is contrary to the "big-endian" standard of most UNIX machines.
The default for MKS cpio
is "big-endian." For example,
the 32-bit hexadecimal number 1234
, written as a
cpio
header using the -h
option,
would be stored in "little-endian" order:
Without the34 12
-h
option, cpio
defaults to "big-endian" ordering:
MKS12 34
cpio
automatically senses the byte ordering of any
archive header being read, and prints a notification to standard output if
byte reversal is present.-I
filecauses input to be read from the specified file, rather than
standard input. The specified file may be the name of a device, for
example, A:
. cpio
reads the raw disk for
the cpio
file.
-l
gives permission to create a link to a file rather than making a separate copy.
-m
resets the modification time of an output file to the modification time
of the source file. Normally, when cpio
copies data
into a file, it sets the modification time of the file to the time when
the file is written. This option has no effect on directories.
-O
filecauses output to be written to the specified file, rather than
standard output. The specified file may be the name of a device,
for example, A:
, and writes the cpio
file
to the raw disk.
-q
assumes all created files are ASCII text. This means that any
\r
(carriage return) characters are stripped, and only the
\n
(newlines) are retained.
-r
lets you rename files as cpio
works. When
extracting, cpio
displays the name of the component
it is about to extract and gives you the chance to specify a name for the
extracted file. If you enter .
as the name,
cpio
processes the file or directory with no
modification to the name. If you just press ENTER,
cpio
skips the file.
-S
for portability reasons, swaps pairs of 16-bit words within long words only when extracting files. This option does not affect the headers.
-s
for portability reasons, swaps pairs of bytes within each 16-bit word only when extracting files. This option does not affect the headers.
-t
prevents file extraction, producing instead a table of file names
contained in the archive. See the description of the
-v
option.
-u
copies an archive file to a target file even if the target is newer
than the archive. Normally, cpio
does not copy the
file.
-V
volpatprovides automatic multi-volume support. cpio
writes output to files whose names are formatted using volpat. The
current volume number replaces any occurrence of #
in
volpat. When you invoke cpio
with this option,
it asks for the first number in the archive set, and waits for you to
press ENTER before it proceeds with the operation.
cpio
issues a similar message when a write error or
read error occurs on the archive; the reasoning is that this kind of error
means that cpio
has reached the end of the volume and
should go on to a new one.
-v
provides more verbose information than usual. cpio
prints the names of files as it extracts them from or adds them to
archives. When you specify both -v
and
-t
, cpio
prints a table of files
in a format similar to that produced by the
ls
-l
command.
-y
when used with -V
, -y
does not
ask for a volume number to begin with, but does ask if
cpio
gets a read or write error.
-z
performs compression. Output is at compression level 5. On input, any
compression level up to 9 is acceptable. In addition,
-z
expands compressed archives on input.
cpio
uses the gzip format to compress files.
-b
,
-S
, and -s
options is effective only for
the file data written. With or without the -c
option, header
information is always written in a machine-invariant format.
To archive the current directory onto diskette in a system-independent (portable) format:find a: -type f | cpio -pvd .
To recover a directory from a portable archive diskette:find . -type f | cpio -ocO a:
To archive a directorycpio -icdm -I a:
xx
that may be larger than a
single diskette, using compression:
find xx -type f | cpio -ocvzV a:#.cpz
0
Successful completion.
1
Failure due to any of the following:
The/dev/mt0
-b
, -C
, -I
,
-O
, -q
, -S
,
-s
, -V
, -y
,
and -z
options are extensions to the x/OPEN standard.
cpio
cannot save files larger than two gigabytes in size in an archive. When storing
archives in ASCII (because of -c
),
cpio
cannot save files larger than eight gigabytes in size
in an archive. However, other programs that extract files from
cpio
archives may be unable to properly extract files larger
than two gigabytes and cpio
issues a warning to that effect
when you attempt to save such a file.
The -u
option of cpio
calls the
sort
utility. To ensure that this
option works correctly, you should make certain that the MKS Toolkit
sort
utility (or one compatible with
it) is the first one located by the command search path.