Duplicating a thing to make two similar things.
Questions tagged [copy]
253 questions
119
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,293
- 2
- 9
- 7
99
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
- 9,689
- 15
- 34
- 53
57
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
- 959
- 2
- 9
- 6
41
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,157
- 5
- 15
- 20
38
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,116
- 3
- 15
- 32
27
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
- 711
- 1
- 6
- 9
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
- 1
- 3
- 10
23
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
- 333
- 1
- 2
- 7
22
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
- 439
- 1
- 6
- 11
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
- 1
- 6
- 11
19
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,…
Xerxes
- 4,133
- 3
- 26
- 33
18
votes
4 answers
cp command prompts on overwrite even with -f
I am trying to copy all newer jpgs from one folder to another using the following command
cp -u --force /home/oldfolder/*.jpg /home/newfolder/
and I get the following promt:
cp: overwrite `/home/newfolder/4095-181.jpg'?
The '-u' I know is working…
icelizard
- 732
- 3
- 9
- 20
17
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
- 403
- 2
- 5
- 11
17
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
- 271
- 1
- 2
- 5
16
votes
7 answers
How to cp file and create directory if not exists?
I want to copy modified files in a svn repository to another directory, while keep their directory structure.
After reading awk and xargs manpage I find a way to get changed filenames like this:
$ svn status -q | awk '{ print $2 }' | xargs -d \\n…
ZelluX
- 395
- 1
- 4
- 11