Saturday, May 11, 2013

Copy/Move Command in Unix(cp,mv)

Copy command is used to copy a file or directory from one place to another place.

Move command is used to move a file or directory from one place to another place.
 
Syntax : cp [-opt] source destination

 cp source path_to_destination      copy a file into another
 cp *.txt dir_name                          copy a file to another directory
 cp file1.txt file2.txt  dir_name      copy file1.txt and file2.txt to another directory
 cp -r dir1 dir2                               copy several files into a directory
 cat fil1 fil2 > fil3                          concatenates fil1 and fil2, and places
                      the result in fil3

Syntax : mv [-opt] source destination

moving files & directories
     mv [opt] file1 file2
     mv [opt] dir1 dir2
     mv [opt] file dir

Example:

mv file1 file2                       #move the file file1 to file2
mv -i file1 file2 file3 dir1    #move the files file1,file2,file3 into the directory dir1
mv dir1 dir2                        #move the directory dir1 to dir2

No comments:

Post a Comment

Price List Query for Item

 SELECT qph.list_header_id,        qph.name,        qph.description,        qphh.start_date_active,        qphh.currency_code,        q...