DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Managing files

Copying files

The cp command copies files. To copy a file, type cp, the name of the file you want to copy, and the name you want to call the copy, then press <Enter>. Unlike DOS, a UNIX system does not tell you that the copy succeeded, but it shows you an error message if it did not. You can use a pathname (a directory) for the name of the copy to put a copy of a file in a particular directory. In this case, unless you specify otherwise, the copied file will be given the same name as the original but in a different directory.

cp mydir/afile /tmp

Try putting a copy of the message of the day file in your home directory:

  1. Type cp /etc/motd $HOME and press <Enter>.

  2. Check if the copy was successful by typing l $HOME/motd and pressing <Enter>. The computer shows you a copy of motd in your home directory if the copy worked.
    $ cp /etc/motd $HOME
    $ l $HOME/motd
    -rw-r--r--  1 susannah techpubs   464 Jun 24 17:47 /u/susannah/motd
    

Next topic: Renaming files
Previous topic: Removing directories

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005