Examples of using the cp command

To copy a file from your current working directory to a subdirectory:

   cp fig2 part2/figure2

This copies the file fig2 from your current working directory to the file figure2 in the subdirectory part2.


To copy a file to the parent directory:

   cp mail.txt ..

This copies the file mail.txt to the directory immediately above the current working directory.

The .. (dot dot) is shorthand for the parent directory.


To copy a file from a subdirectory to a directory elsewhere in the file system:

   cp docs/vi.Z /tmp

This copies the file vi.Z in the subdirectory docs to the directory /tmp.


To copy a file to your home directory:

   cp /usr/local/doc/ue.txt $HOME

This copies the file ue.txt to your home directory. $HOME is the environment variable that contains the value for your home directory.


[Home] [Search] [Index] This site maintained by bondaren@thsun1.jinr.ru