免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2052 | 回复: 4
打印 上一主题 下一主题

[新手入门] 没人熟悉cpio命令吗??? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-06-27 12:23 |只看该作者 |倒序浏览
tar命令常用,现在有个*.cpio的文件

#cd u1
#cpio -id </u0/*.cpio  

没执行成功,只生成了个core文件

郁闷

看了下 ,/bin下也有cpio命令


不熟悉cpio命令,哪位大虾给讲解下


谢谢

论坛徽章:
0
2 [报告]
发表于 2005-06-27 13:46 |只看该作者

没人熟悉cpio命令吗???

cpio -idcmv < 文件

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
3 [报告]
发表于 2005-06-27 14:30 |只看该作者

没人熟悉cpio命令吗???

cpio Command
Purpose
Copies files into and out of archive storage and directories.

Syntax
cpio -o [ a ] [ c ] [ v ] [ B | C Value ] <FileName >;Output

cpio -i [ b ] [ c ] [ d ] [ f ] [ m ] [ M ] [ r ] [ s ] [ t ] [ u ] [ v ] [ S ] [ 6 ] [ B | C Value ] [ Pattern... ] <Input

cpio -p [ a ] [ d ] [ l ] [ m ] [ M ] [ u ] [ v ] Directory <FileName

Description
Attention: 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 is reached.
Note:
The cpio command is not enabled for files greater than 2 Gig in size due to limitations imposed by XPG/4 and POSIX.2 standards.
cpio does not preserve the sparse nature of any file that is sparsely allocated. Any file that was originally sparse before the restoration will have all space allocated within the filesystem for the size of the file.
cpio -o Command
The cpio -o command reads file path names from standard input and copies these files to standard output, along with path names and status information. Avoid giving the cpio command path names made up of many uniquely linked files, as it may not have enough memory to keep track of them and would lose linking information.

cpio -i Command
The cpio -i command reads from standard input an archive file created by the cpio -o command and copies from it the files with names that match the Pattern parameter. These files are copied into the current directory tree. You can list more than one Pattern parameter, using the file name notation described in the ksh command. Note that in this application the special characters * (asterisk), ? (question mark), and [...] (brackets and ellipses) match the / (slash) in path names, in addition to their use as described in the ksh command. The default for the Pattern parameter is an * (asterisk), selecting all files in the Input. In an expression such as [a-z], the minus sign means through according to the current collating sequence.

A collating sequence can define equivalence classes for use in character ranges.

cpio -p Command
The cpio -p command reads file path names from standard input and copies these files into the directory named by the Directory parameter. The specified directory must already exist. If these path names include directory names that do not already exist, you must use the d flag to cause the specified directory to be created.

Note: You can copy special files only if you have root user authority.
Parameters
Directory Specifies the directory.
<FileName Specifies a list of file names for the cpio command to use as input.
>;Output Specifies the output device such as a diskette or file. For more information on using tape devices see the rmt special file.
<Input Specifies the input device (where Input is the Output file created by the cpio -o command). For more information on using tape devices, see the rmt special file.
Pattern Specifies the pattern (as described in the ksh command) to be used with the command. The default for the Pattern parameter is an * (asterisk), selecting all the files in the Input.

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 the access times of the source files to their previous times.
b Swaps both bytes and halfwords.
Note: If there is an odd number of bytes or halfwords in the file being processed, data can be lost.
B Performs block input and output using 512 bytes to a record.
Note: When using the B or C options to extract or create a tape archive, the blocking factor must be a multiple of the physical block size for that tape device.
When using the B or C options to extract an archive from tape, the blocking factor should not be larger than the size of the archive as it exists on the tape.

The B flag and the C flag are mutually exclusive. If you list both, the cpio command uses the last one it encounters in the flag list.

c Reads and writes header information in ASCII character form. If a cpio archive was created using the c flag, it must be extracted with c flag.
C Value Performs block input and output using the Value parameter times 512 bytes to a record. For instance, a -C2 flag changes the block input and output sizes to 1024 bytes to a record.
d Creates directories as needed.
f Copies all files except those matching the Pattern parameter.
l Links files rather than copying them, whenever possible. This flag can only be used with the cpio -p command.
m Retains previous file modification time. This flag does not work when copying directories.
M Retains previous file modification time even when directories are copied.
r Renames files interactively. If you do not want to change the file name, enter a single period or press the <Enter>; key. In the latter case, the cpio command does not copy the file.
s Swaps bytes. This flag is used only with the cpio -i command.
Note: If there is 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 is an odd number of halfwords in the file being processed, data can be lost.
t Creates a table of contents. This operation 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 with the t flag, the output looks similar to that of the ls -l command.
6 Processes an old file (for example, one written in UNIX Sixth Edition format). This flag is usable only with the cpio -i command.

Exit Status
This command returns the following exit values:

0 Successful completion.
>;0 An error occurred.

Examples
To copy files onto diskette, enter:
cpio -ov <filenames >;/dev/rfd0
This copies the files with path names listed in the filenames file 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.
Note: Files with uid's and gid's greater than 65535 cannot be archived using the cpio command. In such instances, the user should use backup and restore.
To copy files in the current directory onto diskette, enter:
ls *.c | cpio -ov >;/dev/rfd0
This copies all the files in the current directory whose names end with .c
To copy the current directory and all subdirectories onto diskette, enter:
find . -print | cpio -ov >;/dev/rfd0
This saves the directory tree that starts with the current directory (.) and includes all of its subdirectories and files. Do this faster by entering:
find . -cpio /dev/rfd0 -print
The -print entry displays the name of each file as it is copied.
To list the files that have been saved onto a diskette with the cpio command, enter:
cpio -itv </dev/rfd0
This displays the table of contents of the data previously saved onto the /dev/rfd0 file in the 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.
To copy the files previously saved with the cpio command from a diskette, enter:
cpio -idmv </dev/rfd0
This copies the files previously saved onto the /dev/rfd0 file by the cpio command back into the file system (specify the -i flag). The d flag allows the cpio command to create the appropriate directories if a directory tree is saved. The m flag maintains the last modification time in effect when the files are saved. The v flag causes the cpio command to display the name of each file as it is copied.
To copy selected files from diskette, enter:
cpio -i "*.c" "*.o" </dev/rfd0
This copies the files that end with .c or .o from diskette. Note that the patterns "*.c" and "*.o" must be enclosed in quotation marks to prevent the shell from treating the * (asterisk) as a pattern-matching character. This is a special case in which the cpio command itself decodes the pattern-matching characters.
To rename files as they are copied from diskette, enter:
cpio -ir </dev/rfd0
The -r flag causes the cpio command to ask you whether to rename each file before copying it from diskette. For example, the message:
Rename <prog.c>;
asks whether to give the file saved as prog.c a new name as it is copied. To rename the file, type the new name and press the Enter key. To keep the same name, you must enter the name again. To avoid copying the file at all, press the Enter key.
To copy a directory and all of its subdirectories, enter:
mkdir /home/jim/newdir
find . -print | cpio -pdl /home/jim/newdir
This duplicates the current directory tree, including the current directory and all of its subdirectories and files. The duplicate is placed in the new /home/jim/newdir directory. The l flag causes the cpio command to link files instead of copying them, when possible.
Note: The performance of cpio to the 9348 Magnetic Tape Unit Model 12 can be improved by changing the default block size. To change the block size, enter the following at the command line:
chdev -1 <device_name>; -a block_size=32k
Files
/usr/bin/cpio Contains the cpio command.

论坛徽章:
0
4 [报告]
发表于 2005-06-27 15:07 |只看该作者

没人熟悉cpio命令吗???

RS9000的这个够详细的了吧。

论坛徽章:
1
数据库技术版块每日发帖之星
日期:2016-05-12 06:20:00
5 [报告]
发表于 2005-06-27 17:06 |只看该作者

没人熟悉cpio命令吗???

cpio -icdv< file
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP