cp command in Linux with examples

 

cp command in Linux with examples


cp stands for copy. This command is used to copy files or group of files or directory. It creates an exact image of a file on a disk with different file name. cp command require at least two filenames in its arguments.


cp [OPTION] Source Destination

cp [OPTION] Source Directory

cp [OPTION] Source-1 Source-2 Source-3 Source-n Directory


Type Of Transfer : 


1. File to Directory


Example 1.1 : file to directory in present directory





Example 1.2 : I am somewhere else but we can transfer file to directory using location also





Example 1.3 : I am somewhere else but we can transfer file to directory using location also



2. Directory to directory


Example 2.1 : I am somewhere else but we can transfer file to directory using location also



Example 2.1 : I am somewhere else but we can transfer file to directory using location also



3. Content Transfer : file to file


3.1 Overwrite mode : Delete previous data



3.2 Append mode : Preserve previous data


the cp command is not typically used for appending data to an existing file. The cp command is usually used to copy files from one location to another


Example 3.2.1 to append the data form one file to another



cat string2.txt >> report.txt




Post a Comment (0)
Previous Post Next Post