CPIO(1,C) AIX Commands Reference CPIO(1,C)
-------------------------------------------------------------------------------
cpio
PURPOSE
Copies files into and out of archived storage and directories.
SYNTAX
+-------+ +-------------+
cpio --- -o ---|1+---+ |---|1 one of |---|
+-| a |-+ | +---------+ |
^| c || +-| B |-+
|| h || | Cvalue |
|| v || +---------+
|+---+|
+-----+
+-------------+ +-------------+ +--- "*" ---+
cpio --- -i ---|1+---------+ |---|1 one of |---| |---|
+-| b c d f |-+ | +---------+ | +- pattern -+
^| m r t u || +-| B |-+ ^ |
|| v s S 6 || | Cvalue | +---------+
|+---------+| +---------+
+-----------+
+-------------+
cpio --- -p ---|1+---------+ |--- directory ---|
+-| a d h l |-+
^| m r u v ||
|+---------+|
+-----------+
-----------------
1 Do not put a blank between these items.
DESCRIPTION
Warning: If you redirect the output from the cpio command to a special file
(device), you should 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.
Note: If you are using different machine types for the input and output of
cpio, you must use the -c flag.
Processed November 8, 1990 CPIO(1,C) 1
CPIO(1,C) AIX Commands Reference CPIO(1,C)
cpio -o
This command reads file path names from standard input and copies these files
to standard output along with path names and status information. Path names
cannot exceed 128 characters. Avoid giving the cpio command path names made up
of many uniquely linked files because it may not have enough memory to keep
track of them thereby losing linking information.
cpio -i
This command reads from standard input an archive file created by the cpio -o
command and copies from the archive file all files with names that match
pattern. These files are copied into the current directory tree. You may list
more than one pattern, using the file name notation described under "sh, Rsh."
However, in this application the special characters "*", "?", and [...] match
the / (slash) in path names, in addition to their use as described under "sh,
Rsh." The default pattern is "*" (which specifies the selection of all files
in the current directory).
In an expression such as [a-z], the - minus means "through" according to the
current collating sequence. A collating sequence may define equivalence
classes for use in character ranges. See the "Introduction to International
Character Support" in Managing the AIX Operating System for more information on
collating sequences and equivalence classes. If you have selected a language
(through the LANG environment variable) that supports multibyte characters, a
collating sequence does not define equivalence classes for use in range
expressions. Therefore, to avoid unpredictable results when using a range
expression to match a class of characters, use a character class expression
rather than a standard range expression. For more information about character
class expressions, see the note on page ed-3 under the ed, red command.
Note: When the cpio files are written, the original values for the owner and
group are set only when the superuser runs the cpio command. This
restriction also applies for the -p option.
cpio -p
This command reads file path names from standard input and copies these files
into the named directory. The specified directory must already exist. If
these path names include directory names that do not already exist, you must
use the d flag as well.
Note: When using the cpio command on internal tape backup units, use the -B
option (5120-byte blocks) or -C option (specified with an even number of
blocks). For example:
find . -print | cpio -ovB > /dev/rst0
The default 512-byte blocks are not a multiple of the PS/2 internal tape
backup unit's block size and, therefore, cannot be used.
Processed November 8, 1990 CPIO(1,C) 2
CPIO(1,C) AIX Commands Reference CPIO(1,C)
FLAGS
All flags must be listed together, without any blanks between them. Not all of
the following flags can be used with each of the -o, -i, and -p flags.
a Resets access times of input files after they have been copied. This
is only done if access permissions permit (see utime in AIX Operating
System Technical Reference).
b Swaps both bytes and halfwords.
Note: If there are an odd number of bytes or halfwords in the file
being processed, data can be lost.
B Performs block input/output, 5120 bytes to a record.
c Writes header information in ASCII character form. Use this flag for
compatibility between machine types.
Cvalue Performs block input/output, value * 512 bytes to a record.
Note: The C flag and the B flag are mutually exclusive. If you list
both, the cpio commands uses the last one it encounters in the
flag list.
d Creates directories as needed.
f Copies all files except those matching pattern.
h Follows symbolic links. Normally, symbolic links are not followed.
This option should be used only with cpio -o or cpio -p command.
l Links files rather than copies them, whenever possible. This flag is
usable only with the cpio -p command.
m Retains previous file modification time. This flag does not work
when copying directories.
r Renames files interactively. If you do not want to change the file
name, enter the current file name or press the Enter key only. In
this last case, the cpio command does not copy the file.
s Swaps bytes. This flag is usable only with the cpio -i command.
Note: If there are an odd number of bytes in the file being
processed, data can be lost.
S Swaps halfwords. This flag is usable only with the cpio -i command.
Note: If there are an odd number of halfwords in the file being
processed, data can be lost.
Processed November 8, 1990 CPIO(1,C) 3
CPIO(1,C) AIX Commands Reference CPIO(1,C)
t Creates a table of contents. This command does not copy any files.
u Copies unconditionally. An older file now replaces a newer file with
the same name.
v Lists file names. If you use this flag with the t flag, the output
looks similar to that of the ls -l command.
6 Processes an old file (one written in UNIX Sixth Edition format).
This flag is usable only with the cpio -i command.
EXAMPLES
1. To copy files onto diskette:
cpio -ov <file names >/dev/rfd0
This command copies the files with path names that are listed in the file
"file names" in a compact form onto the diskette (>"/dev/rfd0"). The -v
flag causes the cpio command to display the name of each file as it is
copied. This command is useful for making backup copies of files. The
diskette must already be formatted, but it must not contain a file system
or be mounted.
2. To copy files in the current directory onto diskette:
ls *.c | cpio -ov >/dev/rfd0
This command copies all the files in the current directory whose names end
with ".c" onto the diskette (>"/dev/rfd0").
3. To copy the current directory and all subdirectories onto diskette:
find . -print | cpio -ov >/dev/rfd0
This command saves the directory tree that starts with the current
directory (.) and includes all of its subdirectories and files. A faster
way to do this is:
find . -cpio /dev/rfd0 -print
The "-print" identify displays the name of each file as it is copied.
4. To list the files that have been saved onto a diskette with the cpio
command:
cpio -itv </dev/rfd0
This command displays the table of contents of the data previously saved
onto /dev/rfd0 in cpio command format. The listing is similar to the long
directory listing produced by the li -l command. To list only the file
path names, use only the -it flags.
Processed November 8, 1990 CPIO(1,C) 4
CPIO(1,C) AIX Commands Reference CPIO(1,C)
5. To copy the files previously saved with the cpio command from a diskette:
cpio -idmv </dev/rfd0
This command copies the files previously saved onto /dev/rfd0 by the cpio
command back into (-i) the file system. The -d flag allows the cpio
command to create the appropriate directories if a directory tree was
saved. The -m flag maintains the last modification time that was in effect
when the files were saved. The -v flag causes the cpio command to display
the name of each file as it is copied.
6. To copy selected files from diskette:
cpio -i "*.c" "*.o" </dev/rfd0
This command copies the files that end with ".c" or ".o" from diskette.
The patterns ""*.c"" and ""*.o"" must be enclosed in quotation marks to
prevent the shell from treating the "*" as a pattern-matching character.
This is a special case in which the cpio command itself decodes the
pattern-matching characters.
7. To rename files as they are copied from diskette:
cpio -ir </dev/rfd0
The -r flag causes the cpio command to ask you whether or not to rename
each file before copying it from diskette. For example, the message:
Rename <prog.c>
asks whether the file saved as "prog.c" should be given a new name as it is
copied in. To rename the file, type the new name and press Enter. To keep
the same name, you must enter the name again. To avoid copying the file at
all, simply press the Enter key.
8. To copy a directory and all of its subdirectories:
mkdir /u/tom/newdir
find . -print | cpio -pdl /u/tom/newdir
This command duplicates the current directory tree, including the current
directory and all of its subdirectories and files. The duplicate is placed
in the new directory "/u/tom/newdir". The -l flag causes the cpio command
to link files instead of copying them, when possible.
RELATED INFORMATION
See the following commands: "ar," "find," and "ln."
See the cpio file format in AIX Operating System Technical Reference.
Processed November 8, 1990 CPIO(1,C) 5
CPIO(1,C) AIX Commands Reference CPIO(1,C)
See "Introduction to International Character Support" in Managing the AIX
Operating System.
Processed November 8, 1990 CPIO(1,C) 6