cpio - Copies files to and from archive storage.
cpio -o[aBcehvV] [-C value] [-M"string"] [-Odevice]
cpio -i[bBcdefmrsStuvz6] [-C value] [-M"string"] [-Idevice] [pattern...]
cpio -p[adlmruvV] directory
Interfaces documented on this reference page conform to industry standards as follows:
cpio: XPG4, XPG4-UNIX
Refer to the
reference page for more information
about industry standards and associated tags.
A hyphen (-) is required before the -i, -I, -o, -O, and -p options; all other options follow -i, -o, or -p without leading spaces and without a hyphen.
[Compaq] The following two options are preceded by a hyphen and must be used separately from the other options. [Compaq] Specifies the input device containing the archive. This argument must be present to import data from a device. [Compaq] Specifies the output device to store the archive. This argument must be present to export data to a device.
Not all of the following options can be used with each of the
Resets the access times of copied files to the current time.
option is also specified, the
access times of the linked files are not reset.)
[Compaq] Swaps both bytes and halfwords. (See also the
there is an odd number of bytes or halfwords in the file being processed,
data can be lost. This option can only be used with
Performs block input/output, 5120 bytes to a record. This
option cannot be used with
is meaningful only with data directed to or from
This option does not work with certain magnetic tape drives. The
mutually exclusive. If you specify both, the last one on the command line
Writes header information in ASCII character form. Specify
this option when POSIX compliance is required and when you are creating or
restoring archives for or from another system.
[Compaq] Performs block input/output using
as the record size. The
options are mutually exclusive. If you
specify both, the last one on the command line is used.
Creates directories as needed.
[Compaq] Read or write
header format. Use this option to read
or write block special or character special files. Any
archives created with the
option of Tru64 UNIX
Version 4.0 are not backward compatible with earlier versions of Tru64 UNIX.
Copies all files except those matching
to follow symbolic
links as if they were normal files or directories. The
command does not follow symbolic links, but instead saves the link text in
Links files rather than copying them, whenever possible. Hard
links are created rather than symbolic (soft) links. This option
can be used only with
Retains the previous file modification time. This option
cannot be used when copying directories.
[Compaq] Specifies the End-of-Media message. This option
is used to customize the message that appears when it is time to change archive
option is valid only when
is also specified.
to ask whether or not to rename
each file before copying it. If you do not want to change the file name,
enter the current file name. You can press
only to have
skip copying the file.
[Compaq] Swaps bytes. This option can be used only with
-i. If there is an odd number of bytes in
the file being processed, data can be lost.
[Compaq] Swaps halfwords. This option can be used only with
-i. If there is an odd number of halfwords
in the file being processed, data can be lost.
Creates a table of contents of the input. This option does
not copy any files.
Copies unconditionally. Otherwise, a file from the archive
with the same name as an existing file in the file system is copied only if
the archived file is the newer one.
Lists file names. If you use this option with the
option, the output looks similar to that of the
[Compaq] Prevents any extended attributes from being archived
with associated files. This option is particularly useful for archiving files
that are to be restored with previous versions of
[Compaq] Positions the tape after the EOF marker on extraction
or listing. The
option lets the user extract
or list tapes that have multiple archives on them one after the other without
error as a result of the tape not being positioned correctly for the next
extraction or listing.
[Compaq] Processes an old file (one written in UNIX Sixth
Edition format). This option can be used only with
A pathname of an existing directory to be used as the target of cpio -p. Expressions making use of a pattern-matching notation similar to that used by the shell for file name pattern matching, and similar to regular expressions. The following metacharacters are defined: Matches any string, including the empty string. Matches any single character. Matches any one of the enclosed characters. A pair of characters separated by `-' matches any symbol between the pair (inclusive), as defined by the system default collating sequence.
The cpio command copies files between archive storage and the file system. It is used to save and restore data from traditional format cpio archives.
There are three versions of the cpio command:
cpio -o (copy out)
This command reads file pathnames from standard input and copies these files to standard output along with pathnames and status information. Output is padded to a 512-byte boundary.
cpio -i (copy in)
This command reads from standard input an archive file created by the cpio -o command and copies from it the files with names that match pattern. These files are copied into the current directory tree. The file permissions are the same as the permissions associated with the files copied out using cpio -o. The owner and group of the files are those of the current user unless the user is superuser, in which case cpio retains the owner and group of the files of the previous cpio -o.
You can list more than one pattern using the file name notation described. The default pattern is *, selecting all files in the archive. In an expression such as [a-z], the hyphen means ``through'' according to the current collating sequence. The collating sequence is determined by the LC_COLLATE environment variable.
cpio -p (directory copy)
This command reads file pathnames from standard input and copies these files into the named directory. The specified directory must already exist. If these pathnames include directory names and if these directories do not already exist, you must use the -d option to cause the directories to be created.
[Compaq] Special files are not supported. Pathnames cannot exceed
128 bytes. Avoid giving
pathnames made up of many
uniquely linked files because
might not have enough
memory to keep track of them and could lose linking information.
[Compaq] Archives created with extended attributes cannot be read by Version 2.0 of the cpio command. The following describes the results of restoring archived files and directories when you use Version 2.0 of the cpio command: [Compaq] You cannot restore an archive directory with extended attributes. The extended attributes are restored as a regular file that cannot be overwritten; the original directory cannot be recreated. In addition, the cpio command restores the archived files containing extended attributes as regular files. When the cpio command restores the original file with the extended attributes, the command fails with errno:20. [Compaq] You cannot archive files with extended attributes. [Compaq] Archives created with the new pax utility and having cpio format, can be restored using only the new pax or cpio commands even if none of the archived files have extended attributes.
To achieve backward compatibility of archived files, use the following
Archive only files that do not have extended attributes.
Use the old
[Compaq] When redirecting the output from
a special file (device), redirect it to the raw device and not the block device.
Because writing to a block device is done asynchronously, there is no way
to know if the end of the device has been reached.
The following exit values are returned:
An error occurred.
To copy files to magnetic tape, enter: cpio -ov < file-list -O/dev/rmt12
The following environment variables affect the execution of
Provides a default value for the internationalization variables
that are unset or null. If
is unset or null, the corresponding value from the default locale is used.
If any of the internationalization variables contain an invalid setting, the
utility behaves as if none of the variables had been defined.
If set to a non-empty string value, overrides the values of
all the other internationalization variables.
Determines the locale for the interpretation of sequences
of bytes of text data as characters (for example, single-byte as opposed to
multibyte characters in arguments and input files) and the behavior of character
classes within bracketed file name patterns.
Determines the locale for the format and contents of diagnostic
messages written to standard error.
Determines the format of date and time strings output when
listing the contents of an archive with the
Determines the location of message catalogues for the processing
Determines the time zone used with date and time strings.
Commands: ar(1), find(1), ls(1), ksh(1), pax(1), Bourne shell sh(1b), POSIX shell sh(1p), tar(1)