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

learn more… | top users | synonyms

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
677 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
197 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. ...
39
votes
4answers
36k 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
315 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?
3
votes
3answers
6k 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 ...
1
vote
1answer
4k 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 ...
1
vote
2answers
232 views

Questions about using scp

In a previous post, I asked a question about simply right-click copy and paste in Nautilus sometimes cannot handle files with special characters in their names under Ubuntu. Later I found that scp ...
9
votes
5answers
11k 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 ...
2
votes
3answers
342 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

rtorrent copy after download

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. ...
1
vote
1answer
274 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. ...
12
votes
3answers
2k views

How is install -c different from cp

What is the difference between install -c and cp? Most installations tend to use install -c, but from the man page it doesn't sound like it does anything different than cp (except maybe set ...
0
votes
1answer
553 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
1answer
51 views

Query on “cp” command

I have a directory say ~/MyWorks which contains the following files in it: a.c, b.c and c.c I want to copy the MyWorks directory to ~/MyAssignments such that only the directory MyWorks is copied and ...
18
votes
4answers
15k views

How to copy symlinks to target as normal folders

i have a folder with symlinks: marek@marek$ ls -al /usr/share/solr/ razem 36 drwxr-xr-x 5 root root 4096 2010-11-30 08:25 . drwxr-xr-x 358 root root 12288 2010-11-26 12:25 .. drwxr-xr-x 3 root ...
1
vote
2answers
2k views

Find files in subdirectories and copy them to another directory with the same subdirectories?

This question is very similar to this one except that I want to maintain the file's original subdirectories. For example if I had /temp/a/a.txt /temp/a/a.jpg /temp/a/b.txt /temp/b/c.txt ...
1
vote
2answers
235 views

argument to cp in backticks doesn't work?

I tried using a command like cp `ls ~/temp/*.xyz | head -1` ./ But that does not work. If I echo the value of command inside back ticks and put it manually in cp command it works. Any ideas?
13
votes
3answers
31k 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 ? ...
7
votes
4answers
4k 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 ...
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 ...
7
votes
3answers
8k 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
1answer
115 views

Moving only the contents of a map and not the map itself on linux

Using the cp command, one can move files and folders on linux. I want to make a new user and move the contents of the skeleton map to their home directory. I use this command: cp -r /etc/skel/ ...
6
votes
6answers
6k 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 ...
69
votes
7answers
114k 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 ...
2
votes
4answers
1k views

cp command force

currently there's a xxx dir already in /home/yyy I'm trying to overwrite it cp -fr ../xxx /home/yyy/ doesn't work still prompts me to overwrite the individual files. how do I fix it?
3
votes
3answers
6k views

How do I use find to copy all found files to a new name in their same directories?

I've got a simple command that does almost what I want. The following will locate all files with a suffix of '_compressed.swf' and copy each into its same directory with a '.bak2' appended: find ...
2
votes
3answers
17k 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.
7
votes
2answers
10k 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 ...
9
votes
5answers
48k 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 ...
1
vote
1answer
1k views

Copy directory from ext3 to FAT32 ignoring symlinks, pipes, etc

I'm trying to write a shell script in which I recursively copy a directory to a USB stick. I need the return value of the copy operation for error-checking purposes. I've tried cp -a /var/mydir ...
110
votes
7answers
87k 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 ...
3
votes
7answers
968 views

How do I make “cp” in OS X not delete files?

Here's the best way to describe this: dirA dir1 file1.txt file3.txt dirB dir1 file1.txt file2.txt I want to copy the contents of dirB into dirA. cp -R dirB/* dirA ...
6
votes
5answers
5k views

cp -r -l in MacOS (recursive copy preserving hard links)

I'm trying to copy a directory tree recursively preserving hardlinks to the file. Using gnu cp, this would work with the -l flag. cp would then recreate the directory structure, but wouldn't need to ...