• Keine Ergebnisse gefunden

copy file archives in and out Syntax

cpio -0 [acBvV] [-C bufsize] [[-0 file] [-K volumesize] [-M mes-sage]]

cpio -i [BcdmrtTuvVfsSb6k] [-C bufsize ] [[-I file] [-K volumesize ] [ -M message] ] [pattern ... ]

cpio -p [ adlmuvV] directory

Description

cpio -0 (copy out) reads the standard input to obtain a list of path names and copies those files onto the standard output together with path name and status information. Output is padded to a 512-byte boundary by default.

cpio -i (copy in) extracts files from the standard input, which is assumed to be the product of a previous cpio -0. Only files with names that match patterns are selected. patterns are regular expres-sions given in the filename-generating notation of sh(C). In patterns, metacharacters ?, *, and [ ... J match the slash (I) character, and backslash (\) is an escape character. A! metacharacter means not.

(For example, the !abc* pattern would exclude all files that begin with abc.) Multiple patterns may be specified and if no patterns are speci-fied, the default for patterns is

*

(i.e., select all files). Each pattern must be enclosed in double quotes otherwise the name of a file in the current directory is used. 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

-0 . 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 -0 . NOTE: If cpio -i tries to create a file that already exists and the existing file is the same age or newer, cpio will output a warning 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. Archives of text files created by cpio are portable between implementations of UNIX System V.

March 15, 1991 ePIO-1

ePlo (e) ePlo (e) 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 -pia is specified.

-b Reverse the order of the bytes within each word. Use only with the -i option.

-B Input/output is to be blocked 5,120 bytes to the record. The default buffer size is 512 bytes when this and the -C options are not used.

(.8 does not apply to the pass option; -8 is meaningful only with data directed to or from a character-special device, e.g., Idev/rdsklfOqlSdt. )

-c Write header information in ASCII character form for portability.

Always use this option when origin and destination machines are different types.

-C bujsize

Input/output is to be blocked bujsize bytes to the record, where buf-size is replaced by a positive integer. The default buffer size is 512 bytes when this and -8 options are not used. (-C does not apply to the pass option; -C is meaningful only with data directed to or from a character-special device, e.g., Idev/rmtlcOsO.) When used with the -K option, bujsize is forced to be a lK multiple.

-d directories are to be created as needed.

-f Copy in all files except those in patterns. (See the paragraph on cpio -i for a description of patterns.)

-I file cor-rupted or out of sequence, this option lets you read only those files with good headers. (For cpio archives that contain other cpio archives, if an error is encountered, cpio may terminate prema-turely. cpio will find the next good header, which may be one for a smaller archive, and terminate when the smaller archive's trailer is encountered.)· Used only with the·i option.

·1 Whenever possible, link files rather than copying them. Usable only with the -p option.

March 15, 1991 CPIO-2

ePlo (e) ePlo (e) -m

Retain previous file modification time. This option is ineffective on directories that are being copied.

-K volumesize

Specifies the size of the media volume. Must be in lK blocks. For example, a 1.2 MB floppy disk has a volumesize of 1200. Must include the -C option with a bufsize multiple of lK.

-M message

Define a message to use when switching media. When you use the -0 or -I options and specify a character-special device, you can use this option to define the message that is printed when you reach the end of the medium. One %d can be placed in the mes-sage to print the sequence number of the next medium needed to continue.

-0 file

Direct the output of cpio to file. If file is a character-special de-vice, when the first medium is full, replace the medium and type a

carria~e return to continue to the next medium. Use only with the

-0 optIon.

-r Interactively rename files. If the user types a null line, the file is skipped. If the user types a ".", the original pathname will be copied. (Not available with cpio -p.)

-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.

-T Truncate long filenames to 14 characters. Use only with the -i option.

-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: causes a list of file names to be printed. When used with the ·t option, the table of contents looks like the output of an Is -1 command [see Is(C)].

-v

SpecialVerbose: print a dot for each file seen. Useful to assure the user that cpio is working without printing out all file names.

·6 Process an old (i.e., UNIX System Sixth Edition format) file. Use only with the ·i option.

NOTE: cpio assumes 4-byte words.

March 15, 1991 CPIO-3

ePlo (C) ePlo (e) If cpio reaches end of medium (end of a diskette for example) when writing to (-0) or reading from (;.i) a character-special device, and -0 and -I are not used, cpio will print the message:

ff

you want to go on, type device/file name when ready.

To continue, you must replace the medium and type the character-special device name (/dev/rdsk/fOqISdt for example) and a carriage return. You may want to continue by directing cpio to use a different device. 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 -0, it groups the files so they can be directed (» to a single file ( •• /newfile). The-c option insures that the file will be portable to other machines. Instead of Is(C), you could use find(C), echo(C), cat(C), etc., to pipe a list of names to cpio. You could direct the output to a device instead of a file.

Is

I

cpio .,.oc > .. Inewfile

cpio -i uses the output file of cpio -0 (directed through a pipe with cat in the example), extracts those files that match the patterns (memo/ai, memolb *), creates directories below the .current directory as needed (-d option), and places the files in the appropriate directories. The-c option is used when the file is created with a portable header .. If no patterns were given, all files from newfile would be placed in the directory.

cat new file

I

cpio -icd "memo/al" "memo/b*"

cpio -p takes the file names piped to it and copies or links (-I option) those files to another directory on your machine (newdir in the exam-pIe). The -d options says to create directories as needed. The-m option says retain the modification time. [It is important to use the -depth option of find (C) to generate path names for cpio. This elim-inates problems cpio could have trying to create files under read-only directories. ]

find. -depth -print

I

cpio -pdlmv newdir

See Also

cat(C), echo(C), find(C), Is(C), tar(C), cpio(F)

March 15, 1991 ePIO-4

ePlo (e)

Notes

1) Path names are restricted to 256 characters.

2) Only the super-user can copy special files.

3) Blocks are reported in 512-byte quantities.

ePlo (e)

4) If a file has 000 pennissions, contains more than 0 characters of data, and the user is not root, the file will not be saved or restored.

Standards Conformance

cpio is conform ant with:

AT&T SVID Issue 2, Select Code 307-127;

and The X/Open Portability Guide II of January 1987.

March 15, 1991 CPIO-5

CRON (C) CRON (C)

eran

executes commands scheduled by at, batch, and