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

learn more… | top users | synonyms

0
votes
0answers
6 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 ...
0
votes
0answers
17 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
255 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 ...
0
votes
1answer
22 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 ?
0
votes
2answers
30 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
11 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 ...
1
vote
3answers
160 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 - ...
0
votes
0answers
33 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
31 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
23 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
104 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 ...
1
vote
2answers
374 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 ...
2
votes
2answers
567 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
96 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
26 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 ...
4
votes
2answers
721 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 ...
0
votes
0answers
72 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
174 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
296 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 ...
0
votes
0answers
36 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 ...
0
votes
1answer
193 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 ...
-2
votes
2answers
94 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
77 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
164 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 ...
0
votes
0answers
30 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 ...
0
votes
1answer
113 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 ...
0
votes
1answer
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. I get the same error whether I use cp or scp. Here is my input at the resulting error: ...
1
vote
1answer
333 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?
39
votes
8answers
5k 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 ...
1
vote
0answers
116 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. ...
0
votes
1answer
258 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
2answers
188 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 ...
0
votes
1answer
53 views

How to copy a list files to a list of directories or subdirectories

I'm trying to figure out how to copy a list of files to a list of subdirectories. eg. I have 300 files to copy into 300 subdirectories - 1 to 1. file1 -> dir1/sub file2 -> dir2/sub file3 ...
0
votes
2answers
769 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
1k 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 ...
4
votes
1answer
487 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
1answer
85 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
776 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
1answer
350 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 ...
0
votes
3answers
95 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 ...
5
votes
3answers
3k 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
171 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 ...
4
votes
4answers
197 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 ...
3
votes
2answers
315 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
3answers
523 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 ...
0
votes
1answer
57 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
619 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. ...
3
votes
2answers
2k 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
236 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 ...
2
votes
1answer
208 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 ...