Questions tagged [cp]

cp is a UNIX command used to copy a file

Description

cp copies SOURCE to the destination DEST, or multiple SOURCE(s) to directory DIRECTORY.

Syntax

cp [OPTION]... [-T] SOURCE DEST

cp [OPTION]... SOURCE... DIRECTORY

cp [OPTION]... -t DIRECTORY SOURCE...

Related commands

824 questions
-1
votes
2 answers

Can using cp command corrupt files transferred across different filesystems? Should I be using something like rsync instead?

I am trying to copy files from one hard drive to another in my home server using the cp command. I am copying from an NTFS-formatted partition to an ext4 partition on a new hard drive I have installed. Is it possible for the cp command to corrupt…
toolshed
  • 1,919
  • 9
  • 38
  • 50
-1
votes
1 answer

Using a while/for loop with the 'find' command to copy files and directories

I have the follwoing problem: I want to make a script that backups a certain directory completely to another directory. I may not use cp -r or any other recursive command. So I was thinking of using a while or for loop. The directory that needs to…
Mavix
  • 181
  • 1
  • 3
  • 13
-2
votes
1 answer

Using regex and cp: cannot stat

I am trying to copy files over from an old file structure where data are stored in folders with improper names to a new (better) structure, but as there are 671 participants I need to copy, I want to use regex in order to streamline it (each…
-2
votes
1 answer

Why do `rsync` and `cp` incorrectly create empty files?

I am running rsync version 3.0.8 and cp 8.32 on a Windows 10 host via git-bash. I have a git server running in a container that uses a hard drive attached to the host. Now I try to backup that server files and keep failing no matter if I use rsync…
TimFinnegan
  • 583
  • 5
  • 17
-2
votes
1 answer

I have two identical answers for a coding question in Python and C++ but somehow Python passes all the testcases and C++ solution doesn't

The question is - A large binary number is represented by a string A of size N and comprises of 0s and 1s. You must perform a cyclic shift on this string. The cyclic shift operation is defined as follows: If the string A is [A0, A1, A2, A3,.....,…
MM1
  • 1
-2
votes
2 answers

Copy files from one folder to another folder with filters

I have these files in my source folder source_path/date=20191230/somefile.txt source_path/date=20191231/somefile.txt source_path/date=20200101/somefile.txt source_path/date=20200102/somefile.txt If I do the bellow command all files will be copied…
Ajay Chinni
  • 780
  • 1
  • 6
  • 24
-2
votes
3 answers

Printing all elements in array of Vector

int n=1000000; vector divisors[1000001]; void solve() { for(int i=1; i<=n; i++) for(int j=i; j<=n; j+=i) divisors[j].push_back(i); } Now, I want to print all the elements of the divisors.…
-2
votes
1 answer

cp -R: create special files rather than copying them as normal files

Reading up on cp -R, what do these mean: create special files rather than copying them as normal files Created directories have the same mode as the corresponding source directory, unmodified by the process' umask I assume by mode they mean for…
Snowcrash
  • 80,579
  • 89
  • 266
  • 376
-2
votes
1 answer

How to automate cp with user input on linux

I want to automate CP to make it easier as I tend to use linux to do alot of data recovery and permission stripping. I know something similar can be done on windows where you enter the path for input and output then it just dumps with already…
-2
votes
1 answer

what are the difference between the Powershell commands cp and cp -r, rm and rmdir

I am learning the commands in PowerShell. what is the difference between cp and cp -recurse ? What is the difference between rm and rmdir ? is rm just short for rmdir?
-2
votes
1 answer

Error while trying to copy file to many files using cp

Error when running this command, i think the command is clear to get the idea. cp file.txt /folder/*/*/*/file.txt
MoJo
  • 44
  • 7
-2
votes
1 answer

BASH: How to determine whether copying has finished?

I need to copy files from several folders by separate cp commands. How to ensure that every command ended only after what files are actually copied to disk? How can I find out that the copying was finished? Thanks
peterko
  • 503
  • 1
  • 6
  • 18
-2
votes
2 answers

Detect usb device name automatically on connection

When I am trying to copy directory from Linux home directory to usb drive(pen drive), In the case of following command cp -r /home/directoryname /media/usbname(pendrivename) it is working fine. But I am looking the command , copy the directory with…
nalini
  • 112
  • 5
-2
votes
1 answer

Obtaining absolute path of files in C

I need a method to obtain the absolute path of a file in C programming language for the implementation of 'cp' UNIX's command. The objective is show an error when the source path and destination path are the same. There are multiple possibilities,…
abii
  • 11
  • 1
  • 3
-2
votes
2 answers

Rename Two files in the Same Folder

Files events-number1.10a.pdf Result events-number1.10a.docx.pdf Ideal events-number1.10a.pdf events-number1.10a.docx.pdf
Dmomo
  • 83
  • 1
  • 1
  • 12
1 2 3
54
55