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

learn more… | top users | synonyms

0
votes
1answer
25 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
14 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
17 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 ...
113
votes
8answers
95k 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 ...
1
vote
1answer
108 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 ...
3
votes
4answers
5k 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 ...
76
votes
7answers
121k 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 ...
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 ...
2
votes
3answers
1k 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
277 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
357 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
972 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 ...
40
votes
4answers
38k 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 ...
1
vote
1answer
198 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
7k 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
274 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
68 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 ...
0
votes
0answers
16 views

How do I copy a Mac volume using cp?

I have researched this for hours. In Single User Mode, I used cp -Rpvn /* /Volumes/MyBackup My external USB is mounted on /Volumes/MyBackup The issue however is that after 24hrs it still has not ...
2
votes
2answers
4k 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 ...
4
votes
2answers
321 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 ...
5
votes
2answers
12k 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 ...
0
votes
0answers
47 views

GNU tar and condensed sparse files

My version of tar doesn't appear to be able to make non-sparse files sparse, though cp does. Are some tar implementations capable of this? (This answer suggests that they may be.) $ dd if=/dev/zero ...
1
vote
0answers
72 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
80 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
32 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 ...
9
votes
5answers
50k 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 ...
0
votes
1answer
81 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 ...
3
votes
3answers
5k 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
66 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 ...
0
votes
1answer
51 views

How to cp multiple file extensions?

How do I cp multiple file extensions, like png, jpg and tif files? I tried: $cp ./*.(jpg|png|tif) ../output/ >bash: syntax error near unexpected token `(` $cp ./01_reliefs/*.\(jpg\|png\|tif\) ...
1
vote
2answers
76 views

Wildcard not working in cp command when using exec

I want to copy all the files in all the directories to the parent directory, but I get the error ./img/* is not a directory For example. Here is the command that I used. Is there a better way to do ...
4
votes
3answers
5k 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 ...
5
votes
4answers
5k views

Cannot copy files from external USB HDD to computer

Hello I have a HDD disk connected with a USB converter to my computer. It consists of two partitions, the first one is mounted automatically and I can grab all the files from it, but the second one I ...
1
vote
0answers
841 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 ...
0
votes
0answers
26 views

cp file in /dev/sdc, now drive isn't readable

So I was trying to instal Arch on my Laptop, and I wanted to copy boot.efi into my usb. cp boot.efi /dev/sdc cp boot.efi /dev/sdc1 cp boot.efi /dev/sdc2 and now its not being read. How can I fix my ...
2
votes
1answer
778 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
1answer
82 views

Mac mv command very slow

On my mac cp command works 9 times faster then mv. Why it is possible? Mac-Pro-AVM-4:2014-10-22 editor$ time cp /Volumes/AVM4_HD5/INGEST/Final\ Cut\ Original\ Media/2014-10-22/Clip\ \#13.mov ...
4
votes
2answers
1k 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 ...
0
votes
1answer
1k 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. I get the same error whether I use cp or scp. Here is my input at the resulting error: ...
1
vote
1answer
149 views

Copying files without losing metadata in Linux

How on Linux can I copy things like music files with “Artist” and “Title” tags without losing the tags? Will rsync work? Will cp? Does either one need any specific switch?
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 ...
39
votes
8answers
4k views

Why is -r recursive necessary when copying a directory in Linux?

My question is why is it required to use the -r (recursive) flag when making a copy of a directory? I.e., why do this: $ cp -r dir1 copyDir1 When would I not want this behavior when copying a ...
0
votes
2answers
841 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 ...
1
vote
0answers
63 views

Is cp -au / cp --archive --update contradictory?

I want to update a directory on a backup disk with new content added to the source, and of course rsync is too slow. cp -a does the trick but is a bulldozer; cp -u should leave existing files alone. ...
13
votes
3answers
32k views

Copy list of files

I have a list of files separated by spaces in a file list.txt. I'd like to copy them to a new folder. I tried to do: cp `cat list.txt` new_folder but it did not work. How would you do this ? ...
0
votes
1answer
149 views

cp: fts_open: No such file or directory / Why?

I have following bash script: #!/bin/bash echo "This script will copy all JPG files inside directory '~/temp/merged':"; pwd; read -r -p "Please confirm, that you want to copy all JPG files [y/N]" ...
0
votes
1answer
126 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 ...
2
votes
1answer
303 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
2answers
82 views

How to make a copy of file in the same directory

This creates a file in the same directy as 'some.file.bak'. find /home/ -ipath "*/temp/some.file" -type f -exec cp {} {}.bak \; How to make a copy in another name such as 'another.file' in the ...