现在的位置: 首页 > 综合 > 正文

非常Linux——翻译cpio指令man

2013年04月20日 ⁄ 综合 ⁄ 共 10000字 ⁄ 字号 评论关闭

NAME
       cpio - 用于复制文件到一个压缩文档或从压缩文档解压

SYNOPSIS
       Copy-out 模式

       在copy-out模式中,cpio复制文件到一个压缩文档。它从标准输入中读取文件名List或一个文件名每行,并写入到标准输出(一般是重定向至一个文件)。一种典型的生成文件名List的方法是使用find指令。

       cpio   {-o|--create}   [-0acvABLV]   [-C   bytes]   [-H   format]   [-M   message]   [-O   [[user@]host:]archive]   [-F  [[user@]host:]archive]
       [--file=[[user@]host:]archive]   [--format=format]   [--message=message][--null]   [--reset-access-time]   [--verbose]    [--dot]    [--append]
       [--block-size=blocks] [--dereference] [--io-size=bytes] [--rsh-command=command] [--help] [--version] < name-list [> archive]

       Copy-in模式

       在copy-in模式中,cpio从压缩文档中解压文件出来,或打印压缩文档中的文件列表。压缩文档是由标准输入中读取。任何不属于cpio指令的参数都被当作是模式表达式(pattern),压缩文档中只有匹配这个模式表达式的文件才会被解压出来。这个模式表达式与shell的通配符有些区别,‘.’在这里不再具有通配符的作用,而是一个普通的字符,通配符能匹配'/'。如果没有给出任何模式表达式,则解压出所有文件。

       cpio {-i|--extract} [-bcdfmnrtsuvBSV] [-C bytes] [-E file] [-H format] [-M  message]  [-R  [user][:.][group]]  [-I  [[user@]host:]archive]  [-F
       [[user@]host:]archive]  [--file=[[user@]host:]archive]  [--make-directories] [--nonmatching] [--preserve-modification-time] [--numeric-uid-gid]
       [--rename] [-t|--list] [--swap-bytes] [--swap] [--dot] [--unconditional] [--verbose] [--block-size=blocks] [--swap-halfwords] [--io-size=bytes]
       [--pattern-file=file]  [--format=format]  [--owner=[user][:.][group]]  [--no-preserve-owner]  [--message=message]  [--force-local]  [--no-abso-
       lute-filenames] [--absolute-filenames] [--sparse] [--only-verify-crc]  [--to-stdout]  [--quiet]  [--rsh-command=command]  [--help]  [--version]
       [pattern...] [< archive]

       Copy-pass模式

       在copy-pass模式中,  cpio复制文件树(文件树由标准输入读取)至目标目录,这个过程其实是copy-in和copy-out的结合,只是没有生成中间的压缩文档而已。第一个不属于cpio指令的参数就是目标目录。

       cpio  {-p|--pass-through}  [-0adlmuvLV]  [-R  [user][:.][group]] [--null] [--reset-access-time] [--make-directories] [--link] [--quiet] [--pre-
       serve-modification-time] [--unconditional] [--verbose] [--dot]  [--dereference]  [--owner=[user][:.][group]]  [--no-preserve-owner]  [--sparse]
       [--help] [--version] destination-directory < name-list

DESCRIPTION

       GNU的cpio是一个用于创建、解压缩压缩文档的工具,也可用作复制文件。它能很好地支持许多cpio压缩格式,比如tar文件

       支持以下cpio压缩格式:binary, old ASCII, new ASCII, crc, HPUX binary, HPUX old ASCII, old tar, and  POSIX.1  tar。tar格式提供了对tar程序的兼容性。默认情况下,cpio为了兼容老版本的cpio程序而使用binary压缩格式。当解压缩时,cpio会自动地识别压缩文档的压缩格式。

OPTIONS
       ‘-0, --null’
              Read  a  list  of  filenames  terminated  by  a  null character, instead of a newline, so that files whose names contain newlines can be
              archived.  GNU find is one way to produce a list of null-terminated filenames.  This option may be used in copy-out and copy-pass modes.

       ‘-a, --reset-access-time’
               不会修改acess time。

       ‘-A, --append’
              追加文件至一个已存在的压缩文档。只能用于copy-out模式。压缩文档必须使用-F或-O指定。

       ‘-b, --swap’
              Swap both halfwords of words and bytes of halfwords in the data.  Equivalent to -sS.  This option may be used in copy-in mode.  Use this
              option to convert 32-bit integers between big-endian and little-endian machines.

       ‘-B’   设置I/O block size为5120byte。默认为512byte。

       ‘--block-size=BLOCK-SIZE’
              设置I/O block size为BLOCK-SIZE * 512 bytes.

       ‘-c’   Identical  to “-H newc”, use the new (SVR4) portable format.  If you wish the old portable (ASCII) archive format, use “-H odc” instead.

       ‘-C IO-SIZE, --io-size=IO-SIZE’
               设置I/O block size为IO-SIZE bytes.

       ‘-d, --make-directories’
              在需要的时候创建目录。可参看下面的示例

       ‘-E FILE, --pattern-file=FILE’
              从文件中读取模式表达式。只能用于copy-in模式。

       ‘-f, --nonmatching’
              只解压不匹配模式表达式的文件。只能用于copy-in模式。

       ‘-F, --file=archive’
              使用指定的压缩文档而不是标准输入或标准输出。To use a tape drive on another machine as the archive, use a filename that
              starts with ‘HOSTNAME:’.  The hostname can be preceded by a username and an ‘@’ to access the remote tape drive as  that  user,  if  you
              have permission to do so (typically an entry in that user’s ‘~/.rhosts’ file).

       ‘--force-local’
              标志通过-F,-I,-O指定的压缩文档是一个本地文件,而不是一个远程文件,即使文件名中包含有':'。

       ‘-H FORMAT, --format=FORMAT’
              指定压缩格式。cpio-in模式会自动识别压缩文档的类型,而copy-out模式使用的是bin压缩格式。其他可用的压缩格式如下:

       ‘bin’  The obsolete binary format.

       ‘odc’  The old (POSIX.1) portable format.

       ‘newc’ The new (SVR4) portable format, which supports file systems having more than 65536 i-nodes.

       ‘crc’  The new (SVR4) portable format with a checksum added.

       ‘tar’  The old tar format.

       ‘ustar’
              The POSIX.1 tar format.  Also recognizes GNU tar archives, which are similar but not identical.

       ‘hpbin’
              The obsolete binary format used by HPUX’s cpio (which stores device files differently).

       ‘hpodc’
              The portable format used by HPUX’s cpio (which stores device files differently).

       ‘-i, --extract’
              运行copy-out模式

       ‘-I archive’
              与-F一样

       ‘-k’   忽略,用于兼容老版本的cpio

       ‘-l, --link’
              在复制时使用硬链接来链接文件,而不是实际复制内容。只适用于copy-pass模式

       ‘-L, --dereference’
              复制软链接指向的文件而不是软链接自身。适用于copy-out和copy-pass模式

       ‘-m, --preserve-modification-time’
              维持mtime不变

       ‘-M MESSAGE, --message=MESSAGE’
              当硬盘不足时打印MESSAGE,MESSAGE可以包含%d符号用于转换硬盘编号。

       ‘-n, --numeric-uid-gid’
              显示UID,GID,而不是它们的名字,需要与 ‘--verbose option’选项一起使用。

       ‘--no-absolute-filenames’
              在copy-in模式中,压缩文档中的文件即使是绝对路径的,也使用相对于当前目录的路径来解压。

       ‘--absolute-filenames’ (default)
              在copy-in模式中,保持压缩文档中的文件的路径

       ‘--no-preserve-owner’
              Do not change the ownership of the files; leave them owned by the user extracting them.  This is the default for non-root users, so that
              users on System V don’t inadvertently give away files.  This option can be used in copy-in mode and copy-pass mode

       ‘-o, --create’
             运行copy-out模式

       ‘-O archive’
              与-F一样

       ‘--only-verify-crc’
              Verify the CRC’s of each file in the archive, when reading a CRC format archive. Don’t actually extract the files.

       ‘-p, --pass-through’
              运行copy-pass模式。

       ‘--quiet’
              Do not print the number of blocks copied.

       ‘-r, --rename’
              通过交互的方式来修改文件名称

       ‘-R [user][:.][group], --owner [user][:.][group]’
              重新设定ownership

       ‘--rsh-command=COMMAND’
              Notifies cpio that is should use COMMAND to communicate with remote devices.

       ‘-s, --swap-bytes’
              Swap the bytes of each halfword (pair of bytes) in the files.This option can be used in copy-in mode.

       ‘-S, --swap-halfwords’
              Swap the halfwords of each word (4 bytes) in the files.  This option may be used in copy-in mode.

       ‘--sparse’
              Write files with large blocks of zeros as sparse files.  This option is used in copy-in and copy-pass modes.

       ‘-t, --list’
              打印压缩文档内的文件列表

       ‘--to-stdout’
              解压缩至标准输出。只适用于copy-in模式Extract files to standard output.  This option may be used in copy-in mode.

       ‘-u, --unconditional’
              不用询问直接覆盖所有已存在的文件

       ‘-v, --verbose’
              List  the  files  processed,  or  with ‘-t’, give an ‘ls -l’ style table of contents listing.  In a verbose table of contents of a ustar
              archive, user and group names in the archive that do not exist on the local system are replaced by the names that correspond locally  to
              the numeric UID and GID stored in the archive.

       ‘-V, --dot’
              Print a ‘.’ for each file processed.

       ‘--version’
              Print the cpio program version number and exit.

EXAMPLES
       When creating an archive, cpio takes the list of files to be processed from the standard input, and then sends the archive to the standard out-
       put, or to the device defined by the ‘-F’ option.  Usually find or ls is used to provide this list to the standard  input.   In  the  following
       example you can see the possibilities for archiving the contents of a single directory.

       % ls | cpio -ov > directory.cpio

       The ‘-o’ option creates the archive, and the ‘-v’ option prints the names of the files archived as they are added.  Notice that the options can
       be put together after a single ‘-’ or can be placed separately on the command line.  The ‘>’ redirects the cpio  output  to  the  file  ‘direc-
       tory.cpio’.

       If you wanted to archive an entire directory tree, the find command can provide the file list to cpio:

       % find . -print -depth | cpio -ov > tree.cpio

       This  will  take all the files in the current directory, the directories below and place them in the archive tree.cpio.  Again the ‘-o’ creates
       an archive, and the ‘-v’ option shows you the name of the files as they are archived.  see “Copy-out mode”.  Using the ‘.’ in the  find  state-
       ment will give you more flexibility when doing restores, as it will save file names with a relative path vice a hard wired, absolute path.  The
       ‘-depth’ option forces ‘find’ to print of the entries in a directory before printing the directory itself.  This limits the effects of restric-
       tive directory permissions by printing the directory entries in a directory before the directory name itself.

       Extracting  an archive requires a bit more thought because cpio will not create directories by default.  Another characteristic, is it will not
       overwrite existing files unless you tell it to.

       % cpio -iv < directory.cpio

       This will retrieve the files archived in the file directory.cpio and place them in the present directory.  The ‘-i’ option extracts the archive
       and  the  ‘-v’ shows the file names as they are extracted.  If you are dealing with an archived directory tree, you need to use the ‘-d’ option
       to create directories as necessary, something like:

       % cpio -idv < tree.cpio

       This will take the contents of the archive tree.cpio and extract it to the current directory.  If you try to extract the files on top of  files
       of  the  same name that already exist (and have the same or later modification time) cpio will not extract the file unless told to do so by the
       -u option.  see “Copy-in mode”.

       In copy-pass mode, cpio copies files from one directory tree to another, combining the copy-out and copy-in steps  without  actually  using  an
       archive.  It reads the list of files to copy from the standard input; the directory into which it will copy them is given as a non-option argu-
       ment.  see “Copy-pass mode”.

       % find . -depth -print0 | cpio --null -pvd new-dir

       The example shows copying the files of the present directory, and sub-directories to a new directory called new-dir.  Some new options are  the
       ‘-print0’  available  with GNU find, combined with the ‘--null’ option of cpio.  These two options act together to send file names between find
       and cpio, even if special characters are embedded in the file names.  Another is ‘-p’, which tells cpio to pass  the  files  it  finds  to  the
       directory ‘new-dir’.

BUGS
       The  GNU  folks, in general, abhor man pages, and create info documents instead.  The maintainer of cpio falls into  this  category.  Thus this
       man page may not be complete, nor current, and was included in the Red Hat CVS tree because man is a great tool :).

REPORTING BUGS
       Please report bugs via https://bugzilla.redhat.com.

SEE ALSO
       The full documentation for cpio is maintained as a Texinfo manual.  If the info and cpio programs are properly installed at your site, the com-
       mand

              info cpio

       should give you access to the complete manual. The online copy of the documentation is available at the following address:

       http://www.gnu.org/software/cpio/manual

                                                                      CPIO(1L)

抱歉!评论已关闭.