cp command to COPY Files and Directories in Linux - 14 useful and advance Examples

Опубликовано: 02 Октябрь 2024
на канале: Dr. Ghazanfar Latif
1,861
50

cp command to COPY Files and Directories in Linux - 14 useful and advance Examples:

cp file1 ./F2/
Copy file1 to parent folder F2
cp file1 ./F2/file1
Copy file1 to parent folder F2 same as pervious example
cp file1 file2
Duplicate file1 with new name file2 at same location
cp file1 /home/ec2-user/file1
Copy file to another absolute location inside ec2-user
cp /home/ec2-user/file1 file1
Copy file from another location ec2-user and copy it in current terminal directory location.
cp file1 file2 file3 ./F2/
Coping multiple files (3 files) using single command
cp –p file1 ./F2/file1
Preserve mode, ownership and timestamp while copying file
cp –r F5/* ./F2/
Copy all files and folders iteratively (recursively)
cp –v file1 ./F2/
Display the Verbose output during the copy of file1
cp –v –u file1 ./F2/file1
Copy file only if the source file is newer then existing destination file.
cp –n file1 ./F2/file1
Copy file from another location without overwriting if the file already exists there.
cp –s file1 ./F2/
Create symbolic link (shortcut) of the file at destination.
cp –f file1 ./F2/
Copy the file forcefully at the destination location.