Duplicating a thing to make two similar things.
Questions tagged [copy]
327 questions
135
votes
9 answers
How to copy file preserving directory path in Linux?
I have Eclipse projects and ".project" file in them, the directory structure looks like 'myProject/.project'. I want to copy these '.project' files to another directory, but I want the enclosing directory name to be preserved.
Let's say I have…
dhblah
- 1,453
- 2
- 10
- 7
116
votes
6 answers
How to let 'cp' command don't fire an error when source file does not exist?
I'm using Mac OS X.
I'm trying to copying some files with cp command for a build script like this.
cp ./src/*/*.h ./aaa
But this command fires an error if there is no .h file in ./src directory.
How to make the command don't fire the error? (silent…
Eonil
- 11,009
102
votes
10 answers
How do I do Multihop SCP transfers between machines?
I want to copy a file from my machine A to server C, but only have access to server C through server B.
Instead of first transferring to server B, log in and then transfer to server C, Is is possible to transfer the file directly with SCP or similar…
sverrejoh
- 1,121
69
votes
8 answers
Rsync : copying over timestamps only
Currently I have two directories A/ and B/ which are identical in every respect, with the exception of the timestamps. Therefore if I run the command :
rsync --dry-run -crvv A/ B/
then all files are marked "uptodate", whereas the command :
rsync…
artella
- 1,099
48
votes
6 answers
Move files to another directory which are older than a date
I am looking for a solution to move files that are year older from today. My log partition is getting full, but I can not remove them. They are needed for a long long time. Anyway one solution I came up with is:
find /sourcedirectory -mtime 365…
cr0c
- 1,038
45
votes
7 answers
What is the windows command line command to copy files?
What is the windows command prompt command to copy files?
I need to move a file from location A to location B. Also if the folder for location B doesn't' exists I want to have it created.
I need this to be a command line so I can automate it.
The…
David Basarab
- 1,197
34
votes
10 answers
How to fetch multiple files from remote machine to local with Ansible
I would like to copy files from remote directory to local directory with Ansible but fetch module allows me to copy only one file. I have many servers from which I need files (same directory each server) and I don't now how to do this with Ansible.…
maayke
- 781
25
votes
6 answers
Recursively copying hidden files - Linux
Is there an easy way to recursively copy all hidden files in a directory to another directory? I would like to back up just all the settings files in a home directory, not the normal files. I tried:
cp -R .* directory
but it recognizes . and .. and…
Zifre
- 479
24
votes
3 answers
Turning off cp (copy) command's interactive mode (cp : overwrite ?)
Does anyone know how I would turn off the interactive mode when using cp?
I am trying to copy a directory recursively into another and for each file that is getting overwritten I have to answer 'y'.
The command I am using is:
cp -r…
Faisal Vali
- 343
- 1
- 2
- 7
23
votes
7 answers
Copy permissions to identical tree on linux / unix
i have a tree of files with correct permission. then i have a (filewise) identical tree (with different file contents tough) with wrong permissions.
how can i transfer the permissions layout from one tree to another?
yawniek
- 375
20
votes
1 answer
What is fastest way to copy a sparse file? What method results in the smallest file?
BACKGROUND: I'm copying a sparse qcow2 VM image that is 200GB in size, but has 16GB of allocated blocks. I've tried various methods to copy this sparse file within the same server and have some preliminary results. Environment is RHEL 6.6 or…
Steve Amerige
- 463
20
votes
3 answers
Fastest way to copy folder that contains many files via SSH
What is the best way to duplicate files on server via ssh?
In my case: I'm talking about duplicating magento shop. (15000 files ~ 50MB)
cp -a source destination
Is taking hours... (in my case server is 2.4 Xeon, 2GB RAM)
enloz
- 301
20
votes
8 answers
How do I copy a directory tree but not the files in Linux?
I want to copy about 200 directories & subdirectories from one location to another but I don't want to copy the thousands of files within those directories. I am on Linux.
Note: I don't have enough space to copy everything then delete all the files.
Kyle West
- 636
20
votes
3 answers
How to perform a secure rsync between servers across an unsecured network
Basically what I'm asking is, has anyone come across a means by which to wrap rsync inside ssh.
With OpenSSH v4.9+ sftp has some nice options that allow you to chroot the incoming connection and such - and that's a solution that I would look at,…
khosrow
- 4,183
19
votes
6 answers
Which is faster, and why: transferring several small files or few large files?
I soon will have a folder with thousands of files, each file on the order of a few KB. I will need to transfer these across a Windows network from one UNC share to another. In general, is it faster to simply copy the files over en masse, or would…
kestes
- 193