cp - Command-line tool to copy a file

learn more… | top users | synonyms

32
votes
3answers
8k views

Why doesn't cp have a progress bar like wget?

Please note that I don't ask how. I already know options like pv and rsync -P. I want to ask why doesn't cp implement a progress bar, at least as a flag ?
-4
votes
0answers
38 views

Backup script to copy files in multiple directories [closed]

The following script will list keywords from check.conf and search for those keywords in the app dir. If a matching file is found, it then copies that file from App to Data10. I have multiple ...
1
vote
3answers
55 views

How do I create a copy of a file in multiple directories?

I have a folder structure conf/ widget1/ env1.cfg env2.cfg widget2/ env1.cfg env2.cfg widget3/ env1.cfg env2.cfg widget4/ ...
0
votes
3answers
82 views

How do I copy the latest file from one directory to another?

I have 3 zip files in a directory. I want to copy the most recent version to a backup directory. My code works fine for .sh and other files, but not for .zip. Is there something else I have to do? ...
23
votes
9answers
31k views

How to check progress of running cp?

Is it possible to check the progress of running cp process? Some processes respond to various KILL signals so that you can check what is their status. I know that I can run cp with parameter -v but ...
55
votes
8answers
47k views

Is it possible to see cp speed and % copied?

I'm having problems when copy large files using nautilus (it gets stuck) so I need to copy using cp. I would like to know if there is any parameter that shows the % copied and also the transfer ...
1
vote
1answer
65 views

cp: cannot stat error - when filename has Asian characters

I am simply trying to copy files using cp -r /home/user/source/ /home/user/destination/ but it throws me the cp: cannot stat /source/filename.xxx error for some of the files. When I searched for this ...
31
votes
5answers
17k views

Difference Between cp -r and cp -R (copy command)

cp- r is meant to copy files recursively, and cp -R for copying directories recursively. But I've checked, and both appear to copy both files and directories, the same thing. So, what's the difference ...
-1
votes
1answer
24 views

Copy files from find command [closed]

I am trying to copy all *file.log files found using find. The problem is all files are named the same and it is only copying over one file. I need to find a way to rename the files in the command or ...
1
vote
4answers
93 views

How do I suppress error messages from cp?

I am currently looking ways to suppress error command in Linux, in particular, the command cp. I do: root@ubuntu:~$ cp /srv/ftp/201*/wha*/*.jj ~/. cp: cannot stat `/srv/ftp/201*/wha*/*.jj': No ...
3
votes
1answer
87 views

scp command fails executing cp

I am trying to use scp command to copy the r0.res file from local machine to a remote machine. I entered the following command: scp -v /etc/drbd.d/r0.res root@192.168.1.104 and I obtain this error: ...
2
votes
2answers
48 views

copy files from the parent location when I am inside a symbolically linked folder

Suppose I have created two folders in /tmp called parent and child. child contains a file called test-child.txt and parent contains a file called test-parent.txt. Now lets go inside the parent and ...
0
votes
1answer
28 views

? appended to filename while copying from a ssh

I am using the command cp error.log error$HOSTNAME.log the command works properly while running it separately in a server, but if it is run as script which uses ssh I am getting a ? appended to the ...
0
votes
1answer
416 views

Simple bash script taking too long to execute

I wrote the following function in my .bashrc for use instead of rm * : function re() { cp . -R /home/glset/ritwik/trash/ rm * } It works .. but it is very slow. Even for small files it takes ...
2
votes
1answer
441 views

Can I get the backup option of cp and mv to work with directories?

--backup[=CONTROL] make a backup of each existing destination file The man page does say that it works on file. It doesn't seem to have any effect on directories. Is there anyway to make this ...
2
votes
1answer
81 views

How to view progress with sshpass and scp in linux?

In my linux terminal, I am using this command sshpass -p "pass" scp -r me8@host.ca:/cmshome/me/file /home/me/Desktop to download a file with a password in it. Without the sshpass, I can see the ...
0
votes
1answer
183 views

How to copy a file from remote server to local machine?

In my terminal shell, I ssh'ed into a remote server, and I cd to the directory I want. Now in this directory, there is a file called table that I want to copy to my local machine /home/me/Desktop. How ...
2
votes
2answers
78 views

How to test which files will be copied with the cp command?

I'm creating a simple script that copies all files from DIRECTORYA that do not exist in DIRECTORYB. I'm doing this through the use of the cp command: cp -u DIRECTORYA/* DIRECTORYB What I'd like to ...
-3
votes
1answer
32 views

How to copy a sub directory of one directory to another?

How can I copy a directory structure named function under Dept2 directory into Dept3 directory in one shot?
1
vote
1answer
67 views

cp with interactive don't prompt before overwrite

I observed a strange behavior cp. Exactly the point is that cp did not ask me for confirmation, even with the option interactive. A test case looks like this Existing files find * -type f ...
1
vote
3answers
54 views

Replace bunch of files maintaining path

I have directory A and B. Each of them contains another directory with item.json inside. Only item.json file is persistent in directories so I cant copy-paste the directories. A: ./path/Item ...
3
votes
2answers
255 views

Copy files in same folder and replace year in its name

How can I copy a lot of files in the same directory replacing the year in its name? I have this (can be different filename and extensions): filename1-2014.ext filename2-2014.ext filename3-2014.ext ...
1
vote
4answers
64 views

Create copies of files in same directory

Lets say I have a directory with the following files: 1.txt 2.txt 3.txt I want to copy these and basically paste in the same directory making new files eg: 1.txt 1(1).txt 2.txt 2(1).txt 3.txt ...
1
vote
1answer
52 views

How to emulate 'cp -a' on Solaris which does not have it?

How to do a cp -a on a Solaris system which does not support the -a option?
11
votes
4answers
17k views

Using rsync to move (not copy) files between directories?

I have been using rsync to copy files for some time. My understanding is that rsync is faster than cp when some of the files to transfer are already in the destination directory, transferring only the ...
1
vote
3answers
284 views

How to copy files from the folder without the folder itself

I'm trying to copy files and subfolders from A folder without the A itself. For instance, A folder contains next: | file1.txt | file2.txt | subfolder1 Executing next command gives me ...
0
votes
0answers
38 views

POSIX description of cp -R

I just became really confused by the implementation of bash's cp -R command compared to how POSIX words what should happen Given the posix definition, I would expect cp -R srcDir existingDestDir to ...
3
votes
1answer
134 views

Mac OS X combine cp and cat to sequentially copy and rename files in list

I am using a MacBook Pro OS X 2013 model. I have a list of filenames in a text file named list.txt separated by line breaks list.txt exactly like this, but this list is going to be long e.jpeg ...
1
vote
1answer
85 views

what is the purpose of cp -s?

as the answer to this question shows, Is there a difference between hardlinking with cp -l or ln? The purpose for creating the -l option for the cp command is to recursively hard-link (the contents ...
1
vote
1answer
64 views

how is cp -f different from cp --remove-destination?

in the cp manpage, it lists the -f/--force option as: if an existing destination file cannot be opened, remove it and try again for the --remove-destination option it says: remove each existing ...
9
votes
5answers
4k views

pv for directory copy

I need to copy a very large directory (talking in terabytes here) and want to monitor the progress. I found that pv is a nice utility, but how can I use it for copying directories recursively? (pv ...
2
votes
3answers
256 views

Invoking cp from within BASH and using the -u option

Is there a way to have cp's --update option print files that did not copy because the source directory contained a newer version of the file?
1
vote
2answers
177 views

do not show error if file doesn't exist on copy, without sending to dev null

I want to avoid my script posting an error if I try to cp a file that does not exist. However, I would like error messages to print out for any other error, such as insufficient permissions. This ...
1
vote
2answers
46 views

May cp override subdirectories with the same name?

I downloaded an Adobe flash plugin, It includes a .so file and a directory called usr. In this folder, it has sub-folders like bin, lib, lib64, share. In the readme file, it says I need to do the ...
1
vote
2answers
2k views

cp: cannot stat : No such file or directory

I am getting an error when I try to copy a file from my local computer to a remote server with ssh. I get the same error whether I use cp or scp. Here is my input at the resulting error: ...
0
votes
1answer
60 views

Syntactic differences in cp -r and how to overcome them

Let's say we are in a blank directory. Then, the following commands: mkdir dir1 cp -r dir1 dir2 Yield two (blank) directories, dir1 and dir2, where dir2 has been created as a copy of dir1. ...
1
vote
1answer
170 views

“wget --restrict-file-names=windows” seems to fail converting links for NTFS

I've downloaded a website from the net using the wget command-line tool with --restrict-file-names=windows so that once the download is complete I could copy the downloaded files to a mounted Windows ...
1
vote
2answers
128 views

The command 'cp' can only used on block device?

According to my last question I think we can't use 'cp' to copy file to the tape device or device like '/dev/lp0'.But I still don't understand why. To make this question simple enough,just tell me if ...
12
votes
5answers
14k views

Copy specific file type keeping the folder structure

I have a folder structure with a bunch of *.csv files scattered across the folders. Now I want to copy all *.csv files to another destination keeping the folder structure. It works by doing: cp ...
4
votes
3answers
2k views

Multithreaded cp on linux? [duplicate]

Is there a multi-threaded cp command on Linux? I know how to do this on Windows, but I don't know how this is approached in a Linux environment.
3
votes
1answer
116 views

cp and set new user

I configure linux servers with some regularty. And then copy with ssh-copy-id my public key to the root user (/root/.ssh) and edit authorized-keys. If I install additional services, sometimes ...
1
vote
1answer
116 views

Linux command to copy as hard links, while deleting unwanted files?

I'm looking for a command that behaves both like cp -al in only creating hard links rather than copying file contents, and rsync -a --delete in removing files from the destination that are not ...
1
vote
2answers
248 views

How can I copy a file from another directory to the current one?

I have this problem as part of a school assignment: NOTE: In case it's hard to read in the image above, here's the directory tree: $ tree . `-- sample_dir1 `-- sample_dir |-- admin ...
1
vote
1answer
37 views

How to copy with wildcard in directory name?

I would like to copy the html directory inside a directory like cms_drupal_PROJ-1-2 to /var/www. The last digit in the working directory is dynamic so at any given time all I know is ...
0
votes
2answers
318 views

Different sizes after copy [duplicate]

I would like to copy for backup porposes a Linux user home directory with several GBs of data and the usual configuration files. The source directory and the backup directory should exactly have the ...
4
votes
1answer
372 views

How to determine if cp -u actually copied the file?

As the title says, I'm looking for a concise way to check if a file was copied using cp -u. I have a little shell script which updates quite a number of files. At the moment the script echoes a ...
2
votes
1answer
198 views

Copy multiple files and create the target directories at the same time?

I read How can I copy a file and create the target directories at the same time? But the solution there only works if you want to copy one file. How would I copy multiple files into a directory, ...
1
vote
1answer
118 views

Replace cp function by rsync [duplicate]

I'm trying to replace my cp function by an rsync function My cp function is the following find /home/odroid/USBHD/Movies/ -iname "*.mkv" -mtime '-1' -exec cp -n {} /home/odroid/NASVD/Movies \; do ...
0
votes
1answer
1k views

Copying files with multiple extensions

I would like to copy files with multiple extensions to a single destination directory. For example, I can use the following command to copy all .txt files in the working directory to a directory ...
2
votes
4answers
12k views

How to copy or move files without being asked to overwrite?

What I've tried: root@host [/home1]# cp -f hello /home3 cp: omitting directory `hello' root@host [/home1]# cp -rf hello /home3 cp: overwrite `/home3/hello/.buildpath'? y cp: overwrite ...