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

learn more… | top users | synonyms

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. ...
30
votes
4answers
26k 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 ...
0
votes
2answers
43 views

Move and rename files based on their parent's directory

I have a collection of directories that all contain a particular file that is named the same in all the directories. dir1/dirA/file.txt dir1/dirB/file.txt dir1/dirC/file.txt .... dir4/dirX/file.txt ...
0
votes
1answer
599 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 ...
5
votes
3answers
10k 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 ...
69
votes
6answers
49k views

How to copy with cp to include hidden files and hidden directories and their contents?

How can I make cp -r copy absolutely all of the files and directories in a directory Requirements: Include hidden files and hidden directories. Be one single command with an flag to include the ...
0
votes
2answers
298 views

How can I copy a directories contents alone?

I want to copy the contents of ~/old contents to ~/new without the ~/old directory itself However when I do cd ~/new cp ../old ~/new or cd ~ cp -vr ~/old ~/new or cp -vr ~/old/ ~/new/ the ...
6
votes
4answers
3k views

Linux copy to fat32 filesystem: invalid argument

When I copy files from an ext3 partition to a fat32 one using cp: cp -R /ext3/stuff /fat32/partition/ I get invalid argument messages for all files with colons and question marks in. Is there any ...
0
votes
1answer
25 views

Mac 10.6 - Unable to cp and mv files into ~/Library/Screen Savers/

I am trying to use Terminal to copy a file into ~/Library/Screen Savers/, but every time I try to do it, it fails. My command is: cp -r Web.saver '~/Library/Screen Savers/Web.saver' and the result ...
1
vote
1answer
509 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 ...
2
votes
3answers
14k views

cp: reading `filename': Input/output error WHY?

I wish to know what could be the possible cases for this error: cp: reading `filename': Input/output error I am getting this message when I am trying to copy a big file of around 50MB.
1
vote
1answer
16 views

execute script with sudo and check security

I have a script, which I need to execute with sudo. #!/bin/bash cp "$@" /destionation/dir Is it a good script or someone can bypass the restriction destination dir ? Thanks for suggestions.
2
votes
1answer
96 views

copying a file to a hard link

I recently got bit by a misbehaving in a bash script of mine and was wondering: is this the expected system behavior, or is it a bug what are the ideal workarounds Essentially, the problem boiled ...
3
votes
2answers
5k 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 ...
2
votes
2answers
76 views

Why OSX cp -avr get this error: the -R and -r options may not be specified together?

I just want to copy a folder tree to another place like this: cp -avr /blah/blah/htdocs ./ but I got error: cp: the -R and -r options may not be specified together. I followed this tutorial: ...
1
vote
0answers
19 views

Why is tar|tar so much faster than cp?

For recursively copying a directory, using tar to pack up a directory and then piping the output to another tar to unpack seems to be much faster than using cp -r (or cp -a). Why is this? And why ...
1
vote
3answers
97 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
1answer
35 views

AWS S3 cp does not download 40 GB file

I just uploaded a 40GB backup file from my linux EC2 machine to an S3 bucket. However when I want to download it the aws command ends with no message and nothing was copied. Here is my command: ...
0
votes
3answers
66 views

How to copy whole file from command line without changing destination creation time

I want to copy one file's content to another file without replacing the destination file. Because I need to retain the destination file's creation time. It is fine if its modification time gets ...
7
votes
5answers
8k views

How can I copy a (big) directory over another changing only the files that differ?

I have directory a and directory b. They are big. b is almost identical to a. "almost" means that 4-5 files differ, and I don't know which they are. I want to copy b over a, but only the files that ...
0
votes
1answer
67 views

Can I fork a copy command on ReadyNAS SSH?

I have a ReadyNAS 102 with a couple of USB drives attached, and connecting to it from a Windows 8 machine over SSH. There were times I wanted to copy files between volumes on the NAS. Unfortunately I ...
8
votes
5answers
41k views

Copying files with SSH

I am trying to copy a file from my other computer, to another computer. (both running Ubuntu 9.10) So say: I've ssh'ed into the other computer; i 'cd' to the directory; and i entered cp File.zip ...
1
vote
2answers
59 views

Recursive, Non-Overwriting Copy

I've got a directory that contains a bunch of other folders containing CoffeeScript/ JavaScript files. I'm able to compile the CoffeeScript files into a new folder with the same folder structure ...
0
votes
1answer
32 views

Merging two directory trees with same structure, but different contents in Unix

I have two directories with the following structure: A |_0 |_1 |_2 B |_0 |_1 |_2 each 0,1,2 directory contains unique contents. I want all of the contents to simply exist as: A |_0 |_1 |_2 Is ...
0
votes
0answers
127 views

Copy from Debian to mounted CIFS share hangs

I have a backup script run by a cron job on my Debian server. It creates a .tar.gz file from /home and copies it to a mounted CIFS share onto a Windows XP machine. It has been running without a ...
0
votes
3answers
126 views

“cp --parents” equivalent on Mac

The topic explains it -- basically I have a bash script used on a Linux system and a Windows system with Cygwin where the following command works perfectly: cp --parents However, running this same ...
4
votes
4answers
116 views

Why does “cp -r a/. b” behave as it does?

I thought that a and a/. is the same path. However, I've found that cp and rsync copy directory content instead of directory itself when /. is added to the source path. I also tried a/inner/..; this ...
1
vote
0answers
68 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 ...
6
votes
5answers
4k views

How can I use cp to copy a directory but ignore a certain sub directory in Linux

Due to a Hard disk problem I am trying to shift a partition from one hard disk to another. I am following http://www.ibm.com/developerworks/library/l-partplan.html article to do that. In the copying ...
0
votes
0answers
61 views

ISPmanager - change panel access to subdomain

I have a question regarding ISPmanager control panel. It is similar to Plesk and CP, so I use ISPmanager Lite. There is an option in the panel settings tab to change the panel address. All I want to ...
0
votes
1answer
45 views

Copy specific subfolders on linux

I have similar file sturecture: /home/dave/documents/static/ /home/static/ /home/dave/pictures/static/ /home/dave/otherfolders/ ... I want to copy from this directory only folders named static. ...
1
vote
1answer
270 views

Linux: Copy files with dates in filename between two dates

I have a folder full of files where I from time to time need to copy a subset of these to somewhere else for processing. The files have the date they were created in the filename, i.e. ...
0
votes
1answer
500 views

cp linux command options

how i do i copy all files from dir to another dir and escape file already exist and not overwrite it , using cp command under linux centos
1
vote
2answers
340 views

Unix “cp -p”. Can I preserve attributes selectively?

I'd like to copy the modification and access times, but not the user ID. If I use cp -p source target It will copy everything. I'm trying to copy files to a different user but keep the original ...
1
vote
0answers
115 views

File copying times out Single User mode mac

I have an old 2009 MacBook that recently crashed. I can't boot into safe mode, but I can boot into Single User mode, verify my disk, and mount a USB drive and copy files to that USB. However, my ...
0
votes
1answer
103 views

Unix copy for each line in file

I have a file, file_copy, which has: >cat file_copy file1 file2 file3 I want to copy file1, file2, file3 from /source to /dest. One way I know how to do this is to just do: for line in `cat ...
0
votes
1answer
122 views

How do I create numbered backups?

Some GNU utils (e.g., mv and cp) can create numbered backups (foo.~1~). Others (e.g., wget) cannot. I would like to create numbered backups before running tools which overwrite files by default. Here ...
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 ...
2
votes
2answers
2k views

cp command to make bootable iso image usb

A lot of discussions exist here on making a bootable USB stick. Debian manual on installing Wheezy suggest the following: # cp debian.iso /dev/sdX # sync Making sure the USB device is first ...
2
votes
2answers
89 views

I somehow made our linux box's “CP” command act differently than the default, how can I revert it back to default?

Title explains it; Somehow in installing the 'z' directory jumper, I made our linux machines CP command act strangely (for example: it no longer prompts for overwrites, it auto-forces it whether we ...
0
votes
5answers
2k views

Moving a file using PuTTY

I am newbie struggling to move a file on a Linux VPS using PuTTY. I can log in with a user in PuTTY at this point I can navigate to see the file I wish to move ...
1
vote
1answer
370 views

Copy files and rename them by creation date

i have a few directories (1 level) that were added to my server in specific times. the problem is, they are named as a random hash. would it be possible to copy them somewhere and rename by the ...
2
votes
1answer
4k views

Why do we use cp to copy files and not dd? (in unix-derivatives)

For normal file copying in *nix, I've only ever seen people use cp (eg. cp /mnt/mydevice/myfile ~/myfile), but I eventually ran into dd, which appears to do the exact same thing (dd ...
3
votes
1answer
408 views

How to preserve file-create-timestamp while copying files on OS X from command-line?

On OS X when you a copy a file using Finder, the target file has the same creation and modification times as the source file. However when you do so using cp in Terminal both creation and ...
2
votes
2answers
81 views

Running cp -r ~/.ipython ~/some/path/.ipython a second time creates ~/some/path/.ipython/.ipython. How to prevent that?

I am using a script to copy directories to a specified location. When I run cp -r ~/.ipython ~/some/path/.ipython the .ipython dir is copied as expected to the specified location. But when I run this ...
0
votes
1answer
445 views

cp all files in the same directory, but exclude subdirectories/files

I'm looking for a way to do something like this: cp -R jquery-ui-1.10.3/themes/base/minified ui ..but to let it match all files in the minified folder (and only it's root) and except all ...
1
vote
1answer
498 views

Unix command for recursively copying files

I need a unix command for the following: Directory Structure /project /images /products /cup.jpg /laptop.jpg /designs /alpha.jpg ...
0
votes
4answers
622 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 ...
0
votes
1answer
404 views

can not copy big file to usb device

I mount usb device like this: sudo mount /dev/sdb1 /media/usb and then copy a big file which about 1Gb to the device: sudo cp ~/big_file /media/usb Ordinary, if I copy a big file to usb, ...
0
votes
2answers
142 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. ...