Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cpio(1) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ar

find

ln

cpio

cpio

PURPOSE

     Copies files into and out of archive storage and directo-
     ries.

SYNOPSIS
     cpio -o[acBvCvalue]

     cpio -i[BcdmrtuvfsSb6] [ patterns ... ]

     cpio -p[adlmruv] directory


DESCRIPTION

     Warning:   If you  redirect  the output  from  cpio 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.

       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 cpio  path names made up of
     many unique linked files as it may not have enough memory
     to keep track of them  and so would lose linking informa-
     tion.

       CPIO -I

     This command  reads from  standard input an  archive file
     created by  the cpio  -o command and  copies from  it the
     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."  Note, however, that in this appli-
     cation the  special characters "*",  "?", and  [ . .  . ]
     match the /  (slash) in path names, in  addition to their

     use as described under "sh."  The default  pattern is "*"
     (select 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 char-
     acter ranges.   See the "Overview of  International Char-
     acter Support"  in Managing the AIX  Operating System for
     more information  on collating sequences  and equivalence
     classes.

       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 and if these directories do
     not already exist,  you must use the d flag  to cause the
     directory to be created.

     Note: You can copy special files  only if you have super-
     user authority.

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 copied files  to the
             current time.
     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.
     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, cpio uses the last
             one it encounters in the flag list.
     d       Creates directories as needed.
     f       Copies all files except those matching pattern.
     l       Links  files rather  than  copies them,  whenever
             possible.  This flag is usable only with cpio -p.
     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, cpio does not copy the file.
     s       Swaps bytes.  This flag  is usable only with cpio
             -i.

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

             Note:  If there are an odd number of halfwords in
             the file being processed, data can be lost.
     t       Creates a table of  contents.  This 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  (one written in UNIX Sixth
             Edition format).   This flag is usable  only with
             cpio -i.

EXAMPLES

     1.  To copy files onto diskette:

           cpio  -ov  <filenames  >/dev/rfd0

         This copies the files with path names that are listed
         in the  file "filenames" in  a compact form  onto the
         diskette (>"/dev/rfd0").  The -v  flag causes cpio 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 copies  all the  files in the  current directory
         whose names end with ".c".
     3.  To copy the current  directory and all subdirectories
         onto diskette:

           find  .  -print  |  cpio  -ov  >/dev/rfd0

         This saves  the directory  tree that starts  with the
         current directory (.) and  includes all of its subdi-
         rectories and files.  A faster way to do this is:

           find  .  -cpio  /dev/rfd0  -print

         The "-print" displays the name  of each file as it is
         copied.
     4.  To  list  the  files  that have  been  saved  onto  a
         diskette with cpio:

           cpio  -itv  </dev/rfd0

         This displays the table of  contents of the data pre-
         viously  saved onto  /dev/rfd0 in  cpio format.   The
         listing  is similar  to  the  long directory  listing
         produced by li -l.  To list only the file path names,
         use only the -it flags.

     5.  To copy the  files previously saved with  cpio from a
         diskette:

           cpio  -idmv  </dev/rfd0

         This copies the files previously saved onto /dev/rfd0
         by cpio back into (-i)  the file system.  The -d flag
         allows cpio 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 causes cpio 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 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 "*"  as a  pattern-matching
         character.   This is  a  special case  in which  cpio
         itself decodes the pattern-matching characters.
     7.  To rename files as they are copied from diskette:

           cpio  -ir  </dev/rfd0

         The -r flag causes cpio to  ask you whether or not 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  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, press the Enter key alone.
     8.  To copy a directory and all of its subdirectories:

           mkdir  /u/jim/newdir
           find  .  -print  |  cpio  -pdl  /u/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 direc-
         tory  "/u/jim/newdir".  The  -l flag  causes cpio  to
         link files instead of copying them, when possible.

RELATED INFORMATION

     The following commands:  "ar,"  "find," and "ln."

     The cpio  system call  in AIX Operating  System Technical
     Reference.

     "Overview of International Character Support" in Managing
     the AIX Operating System.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026