Sunday, 13 November 2016

To copy files using cp command

CP : This command is use to copy data from source file to target file.Source file may be a new file or may be a existing file.
                                           Syntax:$cp <source file name> <target file name>
Ex:
$cp cities capitals
Here source file cities contains cities name and target file capitals is empty file.

a)To Copy files from one directory to other directory.
                                        Syntax:$cp <source directory name>/<filename>  <target directory name>
Ex:
$cp abc/countries pqr
Here abc and pqr is directory and countries is a file.

b)Multiple files copy into on directory.
                                       Syntax:$cp <sourcefilename1><sourcefilename2>...<target directory name>
Ex:
$cp capitals cities file lmn
Here capitals,cities and file are files and lmn is a directory.
c)Copy source directory to target directory.
                                        Syntax:$cp -R <source directory name> <target directory name>
Ex:
$cp -R lmn xyz
Here lmn directory copied into xyz directory.

No comments:

Post a Comment