cp - Command-line tool to copy a file

learn more… | top users | synonyms

2
votes
1answer
16 views

How to view progress with sshpass and scp in linux?

In my linux terminal, I am using this command sshpass -p "pass" scp -r me8@host.ca:/cmshome/me/file /home/me/Desktop to download a file with a password in it. Without the sshpass, I can see the ...
0
votes
1answer
14 views

How to copy a file from remote server to local machine?

In my terminal shell, I ssh'ed into a remote server, and I cd to the directory I want. Now in this directory, there is a file called table that I want to copy to my local machine /home/me/Desktop. How ...
2
votes
2answers
50 views

How to test which files will be copied with the cp command?

I'm creating a simple script that copies all files from DIRECTORYA that do not exist in DIRECTORYB. I'm doing this through the use of the cp command: cp -u DIRECTORYA/* DIRECTORYB What I'd like to ...
-3
votes
1answer
19 views

How to copy a sub directory of one directory to another?

How can I copy a directory structure named function under Dept2 directory into Dept3 directory in one shot?
1
vote
1answer
43 views

cp with interactive don't prompt before overwrite

I observed a strange behavior cp. Exactly the point is that cp did not ask me for confirmation, even with the option interactive. A test case looks like this Existing files find * -type f ...
1
vote
3answers
49 views

Replace bunch of files maintaining path

I have directory A and B. Each of them contains another directory with item.json inside. Only item.json file is persistent in directories so I cant copy-paste the directories. A: ./path/Item ...
3
votes
2answers
126 views

Copy files in same folder and replace year in its name

How can I copy a lot of files in the same directory replacing the year in its name? I have this (can be different filename and extensions): filename1-2014.ext filename2-2014.ext filename3-2014.ext ...
1
vote
4answers
52 views

Create copies of files in same directory

Lets say I have a directory with the following files: 1.txt 2.txt 3.txt I want to copy these and basically paste in the same directory making new files eg: 1.txt 1(1).txt 2.txt 2(1).txt 3.txt ...
1
vote
1answer
41 views

How to emulate 'cp -a' on Solaris which does not have it?

How to do a cp -a on a Solaris system which does not support the -a option?
8
votes
4answers
16k views

Using rsync to move (not copy) files between directories?

I have been using rsync to copy files for some time. My understanding is that rsync is faster than cp when some of the files to transfer are already in the destination directory, transferring only the ...
1
vote
1answer
414 views

Can I get the backup option of cp and mv to work with directories?

--backup[=CONTROL] make a backup of each existing destination file The man page does say that it works on file. It doesn't seem to have any effect on directories. Is there anyway to make this ...
1
vote
3answers
231 views

How to copy files from the folder without the folder itself

I'm trying to copy files and subfolders from A folder without the A itself. For instance, A folder contains next: | file1.txt | file2.txt | subfolder1 Executing next command gives me ...
0
votes
0answers
37 views

POSIX description of cp -R

I just became really confused by the implementation of bash's cp -R command compared to how POSIX words what should happen Given the posix definition, I would expect cp -R srcDir existingDestDir to ...
3
votes
1answer
91 views

Mac OS X combine cp and cat to sequentially copy and rename files in list

I am using a MacBook Pro OS X 2013 model. I have a list of filenames in a text file named list.txt separated by line breaks list.txt exactly like this, but this list is going to be long e.jpeg ...
1
vote
1answer
49 views

what is the purpose of cp -s?

as the answer to this question shows, Is there a difference between hardlinking with cp -l or ln? The purpose for creating the -l option for the cp command is to recursively hard-link (the contents ...
1
vote
1answer
33 views

how is cp -f different from cp --remove-destination?

in the cp manpage, it lists the -f/--force option as: if an existing destination file cannot be opened, remove it and try again for the --remove-destination option it says: remove each existing ...
9
votes
5answers
3k views

pv for directory copy

I need to copy a very large directory (talking in terabytes here) and want to monitor the progress. I found that pv is a nice utility, but how can I use it for copying directories recursively? (pv ...
2
votes
3answers
253 views

Invoking cp from within BASH and using the -u option

Is there a way to have cp's --update option print files that did not copy because the source directory contained a newer version of the file?
1
vote
2answers
89 views

do not show error if file doesn't exist on copy, without sending to dev null

I want to avoid my script posting an error if I try to cp a file that does not exist. However, I would like error messages to print out for any other error, such as insufficient permissions. This ...
1
vote
2answers
35 views

May cp override subdirectories with the same name?

I downloaded an Adobe flash plugin, It includes a .so file and a directory called usr. In this folder, it has sub-folders like bin, lib, lib64, share. In the readme file, it says I need to do the ...
1
vote
2answers
795 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 with ssh. I get the same error whether I use cp or scp. Here is my input at the resulting error: ...
0
votes
1answer
51 views

Syntactic differences in cp -r and how to overcome them

Let's say we are in a blank directory. Then, the following commands: mkdir dir1 cp -r dir1 dir2 Yield two (blank) directories, dir1 and dir2, where dir2 has been created as a copy of dir1. ...
1
vote
1answer
100 views

“wget --restrict-file-names=windows” seems to fail converting links for NTFS

I've downloaded a website from the net using the wget command-line tool with --restrict-file-names=windows so that once the download is complete I could copy the downloaded files to a mounted Windows ...
23
votes
8answers
28k views

How to check progress of running cp?

Is it possible to check the progress of running cp process? Some processes respond to various KILL signals so that you can check what is their status. I know that I can run cp with parameter -v but ...
48
votes
6answers
39k views

Is it possible to see cp speed and % copied?

I'm having problems when copy large files using nautilus (it gets stuck) so I need to copy using cp. I would like to know if there is any parameter that shows the % copied and also the transfer ...
1
vote
2answers
98 views

The command 'cp' can only used on block device?

According to my last question I think we can't use 'cp' to copy file to the tape device or device like '/dev/lp0'.But I still don't understand why. To make this question simple enough,just tell me if ...
10
votes
5answers
12k views

Copy specific file type keeping the folder structure

I have a folder structure with a bunch of *.csv files scattered across the folders. Now I want to copy all *.csv files to another destination keeping the folder structure. It works by doing: cp ...
4
votes
3answers
1k views

Multithreaded cp on linux? [duplicate]

Is there a multi-threaded cp command on Linux? I know how to do this on Windows, but I don't know how this is approached in a Linux environment.
3
votes
1answer
78 views

cp and set new user

I configure linux servers with some regularty. And then copy with ssh-copy-id my public key to the root user (/root/.ssh) and edit authorized-keys. If I install additional services, sometimes ...
1
vote
1answer
90 views

Linux command to copy as hard links, while deleting unwanted files?

I'm looking for a command that behaves both like cp -al in only creating hard links rather than copying file contents, and rsync -a --delete in removing files from the destination that are not ...
1
vote
2answers
210 views

How can I copy a file from another directory to the current one?

I have this problem as part of a school assignment: NOTE: In case it's hard to read in the image above, here's the directory tree: $ tree . `-- sample_dir1 `-- sample_dir |-- admin ...
1
vote
1answer
33 views

How to copy with wildcard in directory name?

I would like to copy the html directory inside a directory like cms_drupal_PROJ-1-2 to /var/www. The last digit in the working directory is dynamic so at any given time all I know is ...
0
votes
2answers
194 views

Different sizes after copy [duplicate]

I would like to copy for backup porposes a Linux user home directory with several GBs of data and the usual configuration files. The source directory and the backup directory should exactly have the ...
4
votes
1answer
321 views

How to determine if cp -u actually copied the file?

As the title says, I'm looking for a concise way to check if a file was copied using cp -u. I have a little shell script which updates quite a number of files. At the moment the script echoes a ...
2
votes
1answer
147 views

Copy multiple files and create the target directories at the same time?

I read How can I copy a file and create the target directories at the same time? But the solution there only works if you want to copy one file. How would I copy multiple files into a directory, ...
1
vote
1answer
93 views

Replace cp function by rsync [duplicate]

I'm trying to replace my cp function by an rsync function My cp function is the following find /home/odroid/USBHD/Movies/ -iname "*.mkv" -mtime '-1' -exec cp -n {} /home/odroid/NASVD/Movies \; do ...
0
votes
1answer
647 views

Copying files with multiple extensions

I would like to copy files with multiple extensions to a single destination directory. For example, I can use the following command to copy all .txt files in the working directory to a directory ...
2
votes
4answers
9k views

How to copy or move files without being asked to overwrite?

What I've tried: root@host [/home1]# cp -f hello /home3 cp: omitting directory `hello' root@host [/home1]# cp -rf hello /home3 cp: overwrite `/home3/hello/.buildpath'? y cp: overwrite ...
0
votes
0answers
23 views

How to be certain “cp -n -r /dir/ /des/” does not overwrite files.. and is doing its job ? verbose mode?

I run the command cp -n -r /dir/ /backup/ but there is no way to tell what it is doing.. if it is skipping files that already exists.. if it is doing anything.. I tried adding -v option to ...
5
votes
2answers
170 views

Is there a better way than cp to copy millions of files while preserving hard links?

So in this story on the GNU coreutils ML, someone used cp to copy 430 million files and needed to preserve hard links, and just barely got it to finish after 10 days. The big problem was that, in ...
2
votes
1answer
139 views

AIX question on cp command [closed]

I have come across an issue with cp command. We are using ksh and cp command goes like below cp -p $PATH/file_name_${VARIABLE}_???.dat $PATH/file_name_to.dat ??? - is for any three digit numbers. ...
3
votes
2answers
215 views

Using cp to replace a directory of the same name

How can I make cp replace a directory of the same name without removing the existing directory first? cp's default behaviour is to copy the source directory into the destination rather than replace ...
7
votes
2answers
2k views

How to replace a symbolic link with a copy of a file it links to?

Having a (single, no batch filesystem processing needed) symlink, what a command line to use to replace it with a copy of the file it links to?
1
vote
2answers
95 views

How use minimum number of commands to copy all .txt files from all subdirectories to one directory?

I have more than 90 subdirectories and inside each one, there will be a number of .txt files. What I need to do is to copy all those txt files out to one single directory. How can I do that?
1
vote
1answer
714 views

copy filenames with special characters to an external ntfs volume

I'm trying to copy the Documents and Settings folder of a Windows XP system over to an NTFS external disk using a USB Live of Puppy Linux. I encountered am encoding problem for namefiles in which the ...
2
votes
1answer
43 views

rolling snapshot of pictures taken in the last half hour

I've taken this: find -maxdepth 1 -mtime +1 -type f -exec cp '{}' backup \; Which should copy all the regular files in the current directory more than 1 day old to the directory backup (assuming ...
3
votes
1answer
406 views

Move preserves ownership of source files not allowing writes

Kindly Consider: $ id # Me uid=100(user1) gid=200(group1) groups=200(group1) $ ls -l tnsnames.ora # So user1 has only read permission on below file. -rw-rw-r-- 1 oracle dba 411024 Jul 28 2010 ...
2
votes
1answer
94 views

Why does `cp -a . /dir` copy contents instead of directory?

I wanted to copy a directory that I was presently in. I tried cp -a . ~/xyz It copied the contents of the directory, yet this worked: cp -a "$(pwd)" ~/xyz [As desired, this copied the directory ...
1
vote
1answer
242 views

How do I force move something when sudo mv -f doesn't work?

I need to move a 16 GB folder to my external drive, but moving it manually gives me an in use error. I have tried to start in safe mode and moved it but it was still in use. I have run these commands ...
2
votes
1answer
46 views

Installing a new OpenBSD kernel “safely”: why does `make install` go through these extra hoops?

After building a new OpenBSD kernel, the install target of the kernel Makefile does the following: rm -f /obsd ln /bsd /obsd cp bsd /nbsd mv /nbsd /bsd I understand that the first two lines remove ...