cp is the command of the Unix operating system that is used to copy files.

learn more… | top users | synonyms

0
votes
1answer
26 views

backup time machine style

I would like to find a more solid and handy solution to my small problem.. My idea is to backup every midnight my home directory incrementally, so I want only the modified files (of today) to be ...
0
votes
1answer
168 views

Using find command with recursive copy without -r or a while/for loop

I have the following problem. Normally one would use the command find exec cp -r to copy everything from one directory to another. In this case I am not allowed to do so, or use a while/for loop for ...
1
vote
2answers
433 views

Get all files from a directory without read permissions?

In Linux/Unix, if I am inside a directory of another user, but cannot view the contents of the directory by typing "ls," how do I get a copy of all the files? Is the only way to guess what the file ...
1
vote
1answer
77 views

how to join paths to {} inside an -exec option of a find command?

//// SOLVED //// I'm trying to copy several files scattered in a directory structure to another one where such files already exist but without write permission allowed. So I used a find command with ...
1
vote
1answer
165 views

Original files corrupted from cp, maybe bad hard disk

I've been having a big problem with corrupted files on my machine. I'm running Debian Wheezy (very minimal install) on an Acer Aspire One netbook. I've been trying to download a 200 mb file. The ...
0
votes
2answers
568 views

xargs and cp: find-style “{}+” multiple expansion?

I'd like to copy a group of files to destination folder. But without needing to spawn a new instance of cp for each operation. The arg format for cp seems to be: cp src_file1 src_file2 src_file3 ...
1
vote
0answers
682 views

How can I copy files recursively without overwriting the directories

On linux, let's say I have some files like this: dir1/file1 dir2/file2 and I want to copy them to a destination that already have dir1 and dir2 and looks like: dir1/file1 dir1/file1a dir2/file2 ...
3
votes
3answers
3k views

Linux: Copy all files by extension to single dirrectory

I am trying to copy all *.tif files from ./old to the ./new. In ./old i have lots of subdirs with different files, and in ./new i need only TIF files, without folder tree. So, I had tried cp -vR ...
3
votes
1answer
2k views

Is there a shortcut for unix `cp` to copy a file to the current directory with the same filename?

I'm hoping there's a shorter way of copying a file from a given directory to the current working directory than typing cp /path/to/file.txt file.txt I tend to use this command a lot, and reiterating ...
0
votes
0answers
105 views

cp didn't copy all files few files were missing

How is it possible that cp didn't copy all files from a huge directory? I did cp on a large directory with 5000 files. I checked contents with diff and it was not matching! How is this possible? I ...
3
votes
4answers
2k views

Using cp command in linux shell, how do I copy a whole directory into another directory?

I have a directory, let's say, "work": ~/work/ This directory has some sub-folders (d1, d2...) in it and files in these sub-folders. I want to make a backup copy in the same folder, so it would be ...
6
votes
3answers
11k views

how to stop cp: overwrite './xxx' ? prompt

How can I stop the cp command from prompting to overwrite. I want to overwrite all the files with out having to keep going back to the terminal. As these are large files and take some time to ...
2
votes
3answers
164 views

In Power SHell set alias cp to cp -v

I have cp for power shell. But I want to use cp in verbose mode without writing -v. So cp should be aliased to "cp -v" command. How to alias cp to "cp -v" in power shell?
1
vote
0answers
185 views

shortcut to recursively copying a directory preserving modes, ownerships and hard and symbolic links

I am using the following to recursively copy a directory while preserving modes, permissions as well as hard and symbolic links: cp -pr --preserve=links dir-a dir-b However I have the following ...
3
votes
2answers
6k views

Copying many files without stopping on errors on OSX

I need to copy several Gb from an external HD to my moan hd and some files will cause errors. If I do this with the finder, it will stop on the first error. Is there a way to copy everything no ...
1
vote
1answer
1k views

Copy files from a numeric range to another folder

Slightly stumped on what CP command would copy files numbered 14 trough 39 into a directory called Volume2 from the following example: 01.mp3 04.mp3 07.mp3 10.mp3 13.mp3 16.mp3 19.mp3 22.mp3 ...
6
votes
2answers
6k views

How do you use regular expressions with the cp command in Linux?

I am attempting to only copy a subset of files from one directory to another using cp however am greeted with the message cp: cannot stat [^\.php]': No such file or directory. Is there a way to use ...
0
votes
2answers
683 views

cp --update still copies unchanged files

I'm trying to copy only changed files using 'cp -pu' under Linux (Red Hat 6.1, source/destination FS are GlusterFS mounted partitions) but I found that it still tries to copy file seemingly old and ...
0
votes
3answers
182 views

cp command inquiry

If I am in a directory called /usr/share/tcl8.3/encoding, what command would copy all files begining "cp" that also contain an even number (from the following list): cp1250.enc cp1255.enc cp737.enc ...
1
vote
1answer
2k views

Symlink all files in a Folder to a new Folder

Ideally what I am seeking is a way to rename all my anime keeping original files intact without using extra data space The solution I can think of is creating a duplicate folder path to another ...
4
votes
2answers
9k views

Linux permissions and owner being preserved with cp

I can't understand the following behavior: I have a file named someFile under /opt/com/internal/someFile If I do ls -all /opt/com/internal/someFile the permissions are 700 user:userGroup I am root ...
1
vote
1answer
738 views

Using a Linux/Unix terminal to copy many files to a new location

I'm trying to use the a Linux terminal to copy many files to a new location. I tired the command: sudo locate -i *file_I_want* | xargs cp $1 /place_I_want_everything_copied_to/ Which, gives an ...
1
vote
3answers
99 views

How do you distinguish a directory, and it's contents in linux?

Let's say you have this directory tree parent -----child1 -----file0 -----grandchild1 -----file1 -----file2 ...
1
vote
0answers
70 views

Maintaining peak IO potential with DD / CP

I wanted to copy a file (40 gig dataset) from a single drive to a dual disk raid-0 drive. I tried with CP and it sustained read - 4mb and write - 11 mb (doesn't make sense I know (must be the stripe ...
0
votes
2answers
143 views

Different performance for different USB 2.0 devices

I copied a 3.5GB file from my SATA HD to my Seagate USB 2.0 external HD in about 3 minutes. I copied the same 3.5GB file from my SATA HD to my USB 2.0 SanDisk Cruzer and it took more than 15 minutes. ...
0
votes
1answer
8k views

Can't create directory, “permission denied” error

I am executing the following command from my Linux machine. cp -r hwweb-ws-5.0 /home/tomcat/hwweb-1/webapps/ It's displaying the following error: cp: cannot create directory ...
4
votes
3answers
1k views

Multi-core and copy speed

What i want to do is to copy 500K of files. I want to copy within server from one destination to another.It includes emails mostly so many small files. Its over 23 GB only but takes so long (over ...
1
vote
2answers
3k views

Copying a file only when it is newer than the destination

How do I copy a file in Linux only when the file being copied is newer than the version at the destination? If the file at the destination is newer, I want the file copy to not go ahead.
3
votes
3answers
1k views

How to copy one file into multiple subfolders at once on a Linux server?

I have a folder on a Linux server with 35+ subdirectories, along the lines of: aa.foo.bar.baz ab.foo.bar.baz .. bp.foo.bar.baz I have a file that I want to copy into each of those subdirectories. ...
2
votes
1answer
1k views

Don't copy files that cause an input/output error

When copying files from a faulty hd with cp, rsync, or scp, the faulty files which can't be read anymore are also partly copied to the destination directory. Is there an option to automatically skip ...
1
vote
3answers
3k views

Linux: how to copy a file with a certain name pattern for which the exact place in the complex directory-structure is unknown

I want to copy all files with the name XYZ* into one folder. The problem is that the files are in different subfolders and that not even the depth of the folder structure is the same for all files. ...
2
votes
1answer
90 views

Copy everything in a subdirectory across to the relevant subdirectory elsewhere

At the moment I'm doing: for i in mdx/[0-9][0-9].png; do cp $i ../../d_s_c/images/mdx ; done But as well as the directory mdx, I also have other directories called ntt, etc. How can I say 'For ...
1
vote
1answer
160 views

Pass wildcard array to cp

I need help with passing a wild card array to cp, I know it can be done but cant figure it out, ive got 3 files all start with the word somefile but have 3 different extensions somefile.conf ...
1
vote
1answer
544 views

I/O error while cp from CD to HDD

I'm trying to create a local repo from my RHEL6 disk. Some of the .rpms I'm able to copy, others give me this error: cp: reading 'filename': Input/Output error It's the original RedHat disk, and ...
0
votes
2answers
205 views

cp command can't find some directories

I'm trying to copy a bunch of files/directories using a terminal command, cp. The command I'm using is: sudo cp -r *.tests ~/Desktop tests are directories with stuff in them. However I get a few ...
2
votes
1answer
279 views

Symlink all files but copy certain extensions

I'm wondering how I'd be able to symlink all the files in a dir structure and then also copy files of a certain extension in that dir. I'm basically symlinking all files within /foo/a,b,c to ...
3
votes
1answer
1k views

How can I avoid that cp freezes my OS?

I am using cp to copy data like so: cp -r from_here to_there When I do that, my computer freezes and unfreezes periodically. I have 4 CPUs installed and the HD is connected via SATA. from_here and ...
5
votes
1answer
1k views

Why does du -sl show different sizes for the source and result of a cp -rl?

I have used cp -rl to copy a folder. When measuring the size of the source and of the result of the copy du -sl returns slightly different sizes, even though diff confirms that their content are ...
3
votes
3answers
2k views

cp - do not overwrite in makefile

In the makefile for my project, I want it to copy a config file only if the file does not already exist in the destination folder. At the moment I am using: cp -n However, recently someone has ...
0
votes
4answers
640 views

Copy the contents of a directory into another

I would like to copy the contents of a directory into another. I don't want to copy the directory and all files and directories under it, but just the contents of the directory just as if it were a ...
1
vote
1answer
1k views

cp -a is preserving ownership, from non-root user

When I invoke cp -a 1 2 from a non-root user, the ownership is being preserved, despite the fact that file 1 belongs to another user. My understanding was this shouldn't be possible. What is going ...
1
vote
1answer
176 views

Debian: rsync and cp is corrupting contents of CSV files

I have a weird problem. I wrote a script that scans a directory on a samba share (a OpenSUSE server on the LAN) and uses cp to copy certain CSV files to the local Debian server web root at /var/www. ...
33
votes
4answers
29k views

How can I recursively copy files by file extension, preserving directory structure?

At the Linux command line, I'd like to copy a (very large) set of .txt files from one directory (and its subdirectories) to another. I need the directory structure to stay intact, and I need to ...
13
votes
3answers
296 views

Reuse text on a bash command

If i'm writing a long command or just typing an extensive file path, is there any that i can "reuse" it with some command shortcut? e.g: 1.cp /home/myuser/really/big/file/here/and/there.png ...
1
vote
1answer
1k views

permission denied while copying files with root

Ok, how is it possible that I get perm denied when I'm copying files in console. Any ideas?
2
votes
3answers
5k views

how to copy all files from one location to another in linux

I want to copy all the folders and files in the /var/www/ directory to another directory /media/magneto/ How do I do this? I tried this command cp -pRiv /var/www/ /media/magneto/ that didn't ...
0
votes
4answers
2k views

cp -ru -> using the recursive copy and update in linux from my internal drive to a mounted nas

I've mounted my NAS drive under the /media/ directory. I've copied a bunch of files from my current /var/www directory, using cp -Rpv (preserve). Now I want to do a cp -Rup /var/www/ ...
0
votes
1answer
2k views

How to copy files and directories while retaining file permissions in UNIX

How can I copy files and directories from one user to another user on a unix system so that the file permissions don't change? The recipient is not the owner, but I have root permissions. Thanks.
0
votes
2answers
2k views

Copy files off FreeBSD

I have a FreeBSD machine that I have to copy everything off the drive. The fielsystem is UFS and not readable by any other operating system. (great...) I have a USB flash drive (FAT32) I need to copy ...
0
votes
1answer
3k views

How to copy a Read-Only file and make the copy writable with a single cp command?

How to copy a Read-Only file in Linux and make the copy writable with a single cp command in Linux (Ubuntu 10.04)? The --no-preserve and --preserve seemed to be good candidates, except that they ...