Questions tagged [cp]

cp - Command-line tool to copy a file

Copy files.

External reference

cp specification (The Open Group Base Specifications Issue 7, 2018 edition)

777 questions
341
votes
18 answers

Is it possible to see cp speed and percent copied?

I'm having problems when copying large files using nautilus (it gets stuck). I need to copy, using cp. I would like to know if there are any parameters that shows the % copied and also the transfer speed.
user27807
218
votes
7 answers

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 --parents *.csv /target cp --parents */*.csv"…
Mojo
83
votes
16 answers

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 what if forgot to do that, cp is running for a very…
Petr
  • 1,711
63
votes
3 answers

Copy first n files in a different directory

Possible Duplicate: How to move 100 files from a folder containing thousands? Is it possible to copy only the first 1000 files from a directory to another? Thanks in advance
chchrist
  • 733
25
votes
6 answers

How to cp remaining files after failed attempt

I'm trying to copy a large directory from one drive to another. I mistakenly logged out before it was finished so only about 80% of the files copied over. Is there away to copy the remaining files without starting from scratch?
barro32
  • 353
9
votes
2 answers

cp: invalid option -- 'o'

I'm following an installation script on GitHub and one of the steps is: cp sources/openssl/1.0.1p/Android.mk -o sources/openssl/$OPENSSL_VERSION/Android.mk But my terminal threw an error cp: invalid option -- 'o' I checked man cp on my Ubuntu, and…
Adhy Satya
  • 105
  • 1
  • 4
8
votes
4 answers

Copy multiple files from filename X to filename Y?

What I want to do is to copy files within a lexicographic range. Example of files: -rw-r--r-- 1 root root 15276 Oct 5 2004 a2ps.cfg -rw-r--r-- 1 root root 2562 Oct 5 2004 a2ps-site.cfg -rw-r--r-- 4 root root 4096 Feb 2 2007…
Tiax
  • 83
7
votes
3 answers

Effect of 'cp /dev/zero a' when file a exists

If a exists and I type cp /dev/zero a can I be sure the old contents of a will be overwritten, or will I simply get the equivalent of rm a cp /dev/zero a PS. I am not suggesting that this is the correct way securely to delete a file; I am merely…
Toothrot
  • 3,435
6
votes
2 answers

copying a directory+renaming it

I want to copy a directory from: path1/dir1 to path2/dir2 the first time I invoke cp -r path1/dir1 path2/dir2 there's no problem, dir2 is created under path2 ls path2/dir2 bu the 2nd time, dir1 is created under path2/dir2 ls path2/dir2/dir1 Can…
Pierre
  • 1,793
5
votes
2 answers

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 it: mkdir -p test/a mkdir a cp -a test/a a a is…
John Hunt
  • 848
4
votes
0 answers

What should 'cp -r srcpath/.. dstpath' do?

Consider the following: /tmp$ mkdir -p src/{a,b} dst/dstsub; touch src/{a,b}/hello /tmp$ tree src/ dst/ src/ ├── a │   └── hello └── b └── hello dst/ └── dstsub Now run /tmp$ cp -r src/a/.. dst/dstsub/ With GNU cp, this results in the…
ilkkachu
  • 138,973
4
votes
4 answers

What does `cp -x` do?

I know in the man pages it puts it as -x, --one-file-system stay on this file system but can someone explain it to me like I'm five.
jkris
  • 159
3
votes
2 answers

cp: cannot stat permission denied

I have a file called fileArc.c and I was given instructions for an assignment that if I do the command cp fileArc.c /pc that this file would then be accessible in a created folder on my desktop. However when I try using the command I get cp: cannot…
gogov
  • 31
3
votes
2 answers

Why does cp not set source attributes and fail with -p?

I have these files: -rw-rw-r-- 1 root adm 0 Jun 22 11:25 a -rw-rw-r-- 1 wilmes wilmes 0 Jun 22 11:23 b When I cp b over to a as user wilmes why does it keep the original owner of a (root)? I use this command (no aliases): cp b a Why does it…
martinw
  • 133
3
votes
5 answers

cp command does not overwrite existing files

I'm copying files from a git repository into a virtualhost folder, although none of the following commands do overwrite existing files: sudo cp -R /home/git/repo /var/www/website sudo cp -R -f /home/git/repo /var/www/website How can I make sure the…
1
2 3