http://www.technicalpage.net/search/label/SQL

>> cp copy file in UNIX


copy file in UNIX (cp):

Syntax:

cp  Sourcefile  Destinationfile   --- copies contents of Sourcefile  to Destinationfile   , if Destinationfile   does not exist already, then it creates the new file (Destinationfile   ) with given name and copies the contents of the Sourcefile  . While copying the contents, the contents of destination file will be replaced by the contents of source file.

Above statement will copy Source file to Destination file on the current directory. 

Copy file located in different locations:
suppose the two files are in different folder destinations, then "cp" can be used from current folder location as below;

cp  path1/Sourcefile   path2/Destinationfile

cp   /home/folder1/hello.txt   /home/deptfolder/empfolder    ---This will copy hello.txt into the empfolder

More than one files can also be copied at the same time:

cp  file1  file2   /home/folder1/folder2  -- This will copy file1 and file2 from  current  directory  to folder2.

File extension can be changed while copying the file.

Syntax :
cp  file1.ext1   file2.ext2

cp  file1.txt   file2.doc  --- File1.txt  will  be copied to file2.doc (new file2.doc will be created if not  already exists.)



No comments:

Post a Comment