Friday, 11 May 2012

COPY command in Linux

You can copy files from one directory to another directory using command prompt window .The following commands used to copying the files


"cp" --->Copies files from one location to another.


cp sourceDirectory desinationDirectory

"cp test.txt desinationDirectory"

         Copies test.txt in the current directory to the desinationDirectory directory.

"cp /home/public/test.txt /home/public/backup/test.html"

         Copies the test.txt file in the public directory into the public/backup directory as test.html The files are identical however have different names.

"cp *.txt desinationDirectory"

        Copy all files ending in .txt into the desinationDirectory directory.

"cp -r /home/public/files/* /home/public/backup"

         Copies all the files, directories, and subdirectories in the files directory into the backup directory.

"yes | cp /home/public/test/* /home/public/target"

         Copies all the files and subdirectories in test into the target directory. If files with the same name exist or it's prompted to overwrite the file it answers yes.



No comments:

Post a Comment