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

learn more… | top users | synonyms

0
votes
1answer
15 views

Copy Files From Flash Drive To Ubuntu

I am attempting to copy files from my flash drive to my local drive on Ubuntu. This is the command that I ran sudo cp -i /media/owner/ESD-USB/mysql /var/lib/ But that output a message of - and ...
2
votes
1answer
47 views

cp only files, skipping directories

Using cp to copy files from a directory that has an empty directory in it as well results in error return value, which fails my script. Is there a way for it to just skip the directories without ...
5
votes
2answers
1k views

Rsync copying current directory with name

I want to copy current directory to my backup directory: I tried this command rsync -a . ~/backup/ but it just copies the current directory contents instead of creating new directory at the ...
1
vote
1answer
47 views

Copying files while SSHed onto a computer

I am trying to upload some website files to a computer I am SSHed into and I'm not sure the correct command to use. I've tried looking up the cp command instructions but I can't work out what to put ...
1
vote
1answer
16 views

How to copy file only if file sizes between src/dst differ?

I wish to perform a file copy like: cp --verbose /srcfile /dstfile But I only wish to perform the copy if dstfile does not exist or if the dstfile filesize differ from the filesize of srcfile. How ...
1
vote
2answers
960 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 ...
1
vote
1answer
35 views

Replace multiple files recursively

I have a file structure like this: experiment/ ├── foo.txt ├── source-foo.txt └── subdir └── foo.txt I want to take the file source-foo.txt and replace the other foos with it. Just like doing ...
0
votes
0answers
47 views

Copy files and replace a directory

I have the following file structure that comes out of my continuous integration tool: stage/acme-plugin/target/acme-plugin-1.0.0.jar stage/example-plugin/target/example-plugin-2.5.0.jar but what I ...
2
votes
2answers
5k 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 ...
0
votes
0answers
29 views

Copy whole directory including contents to a new dir, as a sub dir

I wish to copy an existing dir (and its contents) as a sub dir of a new dir. Unfortunately with the following command it is copying just the loose files to the new dir. The new dir is not pre-...
2
votes
1answer
22 views

Terminal: cp -r with directories with same name and different case

I'm trying to copy around ~250Gb from one drive to another. Catch is that the destination drive is formatted in NTFS or FAT or something and isn't case-sensitive, and I've got folders I need to copy ...
51
votes
5answers
50k 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 ...
167
votes
10answers
145k 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
0answers
22 views

Grub won't recognise USB stick

I am trying to boot to a USB stick using this guide. But unfortunately Grub won't recognise my usb stick when I type root ([tab], 0). Is there any way to solve this issue? I've tried copying the files ...
4
votes
2answers
277 views

How do you copy directories in Linux in these situations using cp?

Situation 1 How do I copy /home/src/somedir to /dest/ such that the path always ends up as /dest/somedir, regardless of whether /dest/somedir already exists? I want to avoid ending up with /dest/...
9
votes
5answers
5k 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 ...
92
votes
8answers
162k views

How to copy symbolic links?

I have directory that contains some symbolic links: user@host:include$ find .. -type l -ls 4737414 0 lrwxrwxrwx 1 user group 13 Dec 9 13:47 ../k0607-lsi6/camac -> ../../include 4737415 ...
0
votes
1answer
54 views

missing destination file operand when cp

i tried to use the Linux alias: rm='cp $* ~/dustbin; rm $*' but it reported 'missing destination file operand after ~/dustbin' , why didn't cp recognize ~/dustbin as destination ?
1
vote
2answers
691 views

OS X - copy files issue - Resource busy

Calling all OS X experts. I copied two 1Tb drives (ex-Windows) onto a new 2Tb USB 3.0 drive using Finder on the Mac (OS X 10.9). The 2Tb drive is now about 90% full. I now want to duplicate that ...
10
votes
2answers
15k views

Use rsync to copy all files except for certain filenames with a certain extension

I have two same-size flash cards, and I want to copy contents of one to the other based on the following rules: I want all directories and subdirectories in place I want to exclude files of type ....
0
votes
2answers
34 views

Reference cells in column of .csv from command line

I have a column B in my.csv in which each cell references the filename of a document in a directory source_directory/. I'd like to grab each of those names so I can use them as args for other shell ...
0
votes
1answer
15 views

Zsh: prepend $(<list.txt) args with a directory

I'm using cp $(<list.txt) new_folder to copy a list of files (filenames in list.txt) to a new folder. As is the files must be in the same folder as list.txt. Is there an easy way to make this work ...
5
votes
3answers
6k views

Recursive, Non-Overwriting File 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 fine....
4
votes
1answer
748 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 can'...
15
votes
2answers
14k 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 if=/mnt/mydevice/...
1
vote
3answers
400 views

how to copy a directory (folder and its contents) to another directory?

Here is my file structure: - someDirA - folderOne - folderTwo - somefile.txt - someotherfile.txt - someDirB - somefolder What I want 'someDirB' to look like: - someDirB - ...
7
votes
3answers
9k views

Copy file in GNU/Linux with progress bar and rate limiting

Is there any good tool in GNU/Linux that copy files like cp, but also shows progress and limits speed (and changes limit without interruption) like pv? Prototype: find source_directory | cpio -H ...
0
votes
0answers
37 views

Ubuntu file copy fake success?

I am using Ubuntu 14.04. When copying a big folder with lots of files and sub folders from my NTFS U disk to my hard drive, the progress bar indicates that copy is finished. But the destination ...
0
votes
1answer
33 views

Copy matches of recursive search to a new location

I want to search a directory recursively and copy all XML files to a new location. I can identify the files with: ls -R | grep .xml$ or with full paths with: find . -name \*.xml Results of ...
1
vote
1answer
34 views

Keyboard command in shell for skipping file during copy

Probably a stretch but is there a keyboard command that is accepted by cp from the shell (using bash/zsh) to skip a currently copying file for example if I am recursively copying a folder structure of ...
0
votes
0answers
137 views

Linux cp command: Auto-rename files, windows-like, FAT32, file name restrictions, ignore symbolic links

Linux cp command: How can I auto-rename all files to conform to windows or FAT32 formatted device file name restrictions, and ignore all symbolic links? I am trying to copy the contents of my dropbox ...
3
votes
4answers
6k views

cp verbose alternative

I want to list all of the files that are being copied by a cp command but the -v switch doesn't seem to exist on the servers here at work. I'm not sure exactly which OS this is. I think it might be ...
2
votes
3answers
2k views

Allow limited cp access to a sudo enabled user

We have several tier2 admins whom have very limited admin rights granted via sudo; As they have limited experience we really want to put them into a tight set of operations they can perform. One of ...
1
vote
1answer
286 views

linux cp command with rtorrent

so I`m trying to do the following: When rtorrent finishes download, it should copy files from download dir to another dir called uploads, so the file would be in Downloads dir AND in Uploads dir. ...
2
votes
3answers
470 views

Copied directory appears to become larger at destination

I have the following code as part of a shell script: while [ $(ps -ef | awk '{print $2}' | grep -F "$CPPID") ]; do sleep 10 awk -v "usbsize=$(/bin/df | grep -F $DEVICEMOUNTPOINTQ | awk '{...
0
votes
2answers
1k views

Copying all files inside subdirectories and renaming instead of overwriting

I have a number of images inside subdirectories of another directory which I'd like to copy to one single directory so all the images are in one place. After a bit of searching, I found and then ...
1
vote
1answer
213 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. ...
6
votes
6answers
8k 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 ...
2
votes
2answers
921 views

Linux cp command is not silent

I know with a -f cp should be silent but it's not! I do cp -rf Functional Functionalssssssss and if Functional does not exist, it says cannot stat 'Functional'... but I just don't want to see the ...
0
votes
2answers
109 views

Laptop fan not turning on for graphics

About two years ago, I purchased a samsung series 5 (not the ultra book, the NP510r5e). Every now and then, when there I run something graphically demanding, the laptop just shuts down. I first ...
2
votes
2answers
6k views

How to copy all files recursively excluding folders into one destination folder?

I have several folders like /music/1/a.mp3 and /music/2/b.mp3 All of the file names themselves are guaranteed to be different. Is there a way, probably using the Terminal, to copy these files to /...
7
votes
2answers
20k 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
0answers
225 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 ...
0
votes
1answer
544 views

Linux Bash: Moving/Copying files/directories by timestamp

This is the command I am using: find absolute-path -name "*" -amin -120 -exec cp -f absolute-destination {} \; I’m trying to copy a lot of directories from a directory to another directory, but ...
4
votes
3answers
2k 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 ...
0
votes
0answers
39 views

how to update a directory that is a mirror of another one (with hard-links)?

I like using cp -rl dir1 dir2 to make a recursive copy of dir1 into dir2 (using hard links to save storage, and usually followed by rsync to make progressive backups). The issue is that, if dir2 ...
11
votes
5answers
58k views

How can I copy files with SSH?

I am trying to copy a file from my other computer, to another computer. (both running Ubuntu 9.10) So, I've ssh'ed into the other computer; I cd to the directory; and I entered cp File.zip /home/me/...
0
votes
1answer
310 views

In Linux copy file and overwrite only if target is older [duplicate]

How in Linux using cp one can copy file to destination, but if destination exists, then overwrite only if destination is older than source? cp -f always overwrites, but overwrite is needed only if ...
7
votes
3answers
11k 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.
-2
votes
2answers
108 views

Copy sequential files into sequential directories

I need to copy multiple, sequential files into sequential directories. The files have the julian date (day of year) with other info in the file name. The directories are listed by julian date (day of ...