->Title Page
-->File Structure
-->Online Manual
-->Basic Commands
--->Logging In
--->Getting Out
--->Listing files
--->Directory trees
--->Make/Remove Directories
-->Additional Commands
-->Login files
-->Special characters
-->Miscellaneous Tips
-->Things to try
->Vi editor
->Mirror sites
->Further reading

[ Up ]

Unix ---> Copying

The cp (copy) command lets you duplicate a file of choice. Here is an explanation by examples:

    cp cocoon butterfly
makes a duplicate of the file cocoon and gives it the name butterfly. Note that the filenames can include pathnames as well.

    cp /home/cernan/taylor/tex/contract ../contract.bak
makes a copy of the file contract found in the /home/cernan/taylor/tex directory and places it one directory level above the working directory in a file called contract.bak.

If /home/cernan/taylor/tex is a directory, then

    cp report /home/cernan/taylor/tex
will place a copy of report in the /home/cernan/taylor/tex directory with the name report.

    cp /home/cernan/taylor/tex/headlines .
will copy the file headlines in the /home/cernan/taylor/tex directory into the working directory. The name will remain unchanged.

    cp /home/cernan/taylor/tex/* .
will copy all the files (but not the subdirectories) in /home/cernan/taylor/tex into the working directory. You can copy all the subdirectories in the directory and files contained in them by using the -r (recursive) flag as follows:

    cp -r /home/cernan/taylor/tex/* .
Another useful flag is the -i (interactive) flag which prompts you if you are about to overwrite an existing file.

Site Statistics

t a y l o r@l i n u x b o x.c o m

© 1993-1998 Christopher C. Taylor