cpio
flags
[options
]
Copy file archives in from or out to tape or disk, or to another location on the local machine. Each of the three flags -i , -o , or -p accepts different options.
options
] [
patterns
]
Copy in (extract) files whose names match selected
patterns
. Each pattern can include filename metacharacters from the Bourne shell. (Patterns should be quoted or escaped so they are interpreted by
cpio
, not by the shell.) If no pattern is used, all files are copied in. During extraction, existing files are not overwritten by older versions in the archive (unless
-u
is specified).
options
]Copy out a list of files whose names are given on the standard input.
options
]
directory
Copy files to another directory on the same system. Destination pathnames are interpreted relative to the named
directory
.
Options available to the
-i
,
-o
, and
-p
flags are shown respectively in the first, second, and third row below. (The
-
is omitted for clarity.)
i
: 6 b B c C d E f H I k m M r R s S t u v Vo
: a A B c C H L M O v Vp
: a d l L m R u v V
Reset access times of input files.
Append files to an archive (must use with -O ).
Swap bytes and half-words. Words are 4 bytes.
Block input or output using 5120 bytes per record (default is 512 bytes per record).
Read or write header information as ASCII characters; useful when source and destination machines are of differing types.
n
Like
B
, but block size can be any positive integer
n
.
Create directories as needed.
file
Extract filenames listed in
file
from the archives.
Reverse the sense of copying; copy all files
except
those that match
patterns
.
format
Read or write header information according to
format
. Values for format are
crc
(ASCII header containing expanded device numbers),
odc
(ASCII header containing small device numbers),
ustar
(IEEE/P1003 Data Interchange Standard header), or
tar
(tar header).
file
Read
file
as an input archive.
Skip corrupted file headers and I/O errors.
Link files instead of copying.
Follow symbolic links.
Retain previous file modification time.
msg
Print
msg
when switching media. Use variable
%d
in the message as a numeric ID for the next medium.
-M
is valid only with
-I
or
-O
.
file
Direct the output to
file
.
Rename files interactively.
ID
Reassign file ownership and group information to the user's login
ID
(privileged users only).
Swap bytes.
Swap half-words.
Print a table of contents of the input (create no files). When used with the -v option, resembles output of ls -l .
Unconditional copy; old files can overwrite new ones.
Print a list of filenames.
Print a dot for each file read or written (this shows cpio at work without cluttering the screen).
Process a UNIX 6th Edition archive format file.
Generate a list of old files using find ; use list as input to cpio :
find . -name "*.old" -print | cpio -ocBv\ > /dev/rst8
Restore from a tape drive all files whose name contains "save" (subdirectories are created if needed):
cpio -icdv "save" < /dev/rst8
To move a directory tree:
find . -depth -print | cpio -padm /mydir