Questions tagged [file-copy]

Questions regarding copying files from one place to another

Filter by
Sorted by
Tagged with
656
votes
4answers
2.5m views

How to copy files from one machine to another using ssh [duplicate]

I'm using Linux (centos) machine, I already connected to the other system using ssh. Now my question is how can I copy files from one system to another system? Suppose, in my environment, I have two ...
254
votes
9answers
305k views

Copy a file back to local system with ssh

If I'm logged in to a system via SSH, is there a way to copy a file back to my local system without firing up another terminal or screen session and doing scp or something similar or without doing SSH ...
102
votes
4answers
130k views

How to copy-merge two directories?

I have two directories images and images2 with this structure in Linux: /images/ad /images/fe /images/foo ... and other 4000 folders and the other is like: /images2/ad /images2/fe /...
69
votes
5answers
44k views

Is there a way to determine the optimal value for the bs parameter to dd?

On occasion I've seen comments online along the lines of "make sure you set 'bs=' because the default value will take too long," and my own extremely-unscientific experiences of, "well that seemed to ...
64
votes
4answers
11k views

Why use install rather than cp and mkdir?

I've seen in many places used install -d to create directories and install -c to copy a file. Why not use mkdir and cp? Is there an advantage in using install?
63
votes
3answers
140k views

Copy the contents of a file into the clipboard without displaying its contents

How to copy the contents of a file in UNIX without displaying the file contents. I don't want to cat or vi to see the contents. I want to copy them to clipboard so that I can paste it back on my ...
59
votes
3answers
44k views

Why is my PC freezing while I'm copying a file to a pendrive?

I have a really strange situation here. My PC works fine, at least in most cases, but there's one thing that I can't deal with. When I try to copy a file from my pendrive, everything is ok -- I got 16-...
56
votes
6answers
77k views

How to sync two folders with command line tools?

Having migrated to Linux from Windows, I would like to find an alternative software to Winmerge or rather learn command line tools to compare and sync two folders on Linux. I would be grateful if you ...
42
votes
1answer
74k views

rsync to copy files which has changed

I need to copy some files from a particular directory to a different location on a daily basis. I want to copy the changes only, so planning to use rsync. These files follows the following naming ...
40
votes
12answers
90k views

Is there a faster alternative to cp for copying large files (~20 GB)?

I am a graduate student, and the group in which I work maintains a Linux cluster. Each node of the cluster has its own local disk, but these local disks are relatively small and are not equipped with ...
39
votes
7answers
67k views

How do I copy multiple files by wildcard?

I have a folder with a number of files in it ABC.* (there are roughly 100 such files). I want to duplicate them all to new files with names starting with DEF.* So, I want ABC.Page1 ABC.Page2 ABC....
36
votes
7answers
4k views

Is it a UUOC (useless use of cat) to redirect one file to another?

If I want to make the contents of file2 match the contents of file1, I could obviously just run cp file1 file2. However, if I want to preserve everything about file2 except the contents—owner, ...
30
votes
7answers
178k views

Can I transfer files using SSH?

I am using PuTTY on Windows 7 to SSH to my school computer lab. Can I transfer files from my Windows machine to my user on the school machines using SSH?
30
votes
1answer
4k views

What happens when you rsync without a destination?

To make the story short, I did an rsync: rsync -avP user@exampleserver.com:/tmp/ And I forgot to put in my source directory... I really meant to run: rsync -avP /tmp/ user@exampleserver.com:/tmp/ ...
29
votes
2answers
6k views

Why is this binary file transferred over “ssh -t” being changed?

I am trying to copy files over SSH, but cannot use scp due to not knowing the exact filename that I need. Although small binary files and text files transfer fine, large binary files get altered. Here ...
28
votes
3answers
57k views

Copy files with renaming

I have a huge file tree. Some files have same name but in different case, e.g., some_code.c and Some_Code.c. So when I'm trying to copy it to an NTFS/FAT filesystem, it asks me about whether I want ...
26
votes
8answers
16k views

Make disk/disk copy slower

Is there a method of slowing down the copy process on Linux? I have a big file, say 10GB, and I'd like to copy it to another directory, but I don't want to copy it with full speed. Let's say I'd like ...
24
votes
3answers
53k views

Fast way to copy a large file on a LAN

I am having some trouble with NFS, and I'd like to try using just plain old TCP. I have no idea where to begin, though. Hardware-wise, I am using an ethernet crossover cable to network two netbooks. ...
23
votes
5answers
4k views

How do programs that can resume failed file transfers know where to start appending data?

Some file copying programs like rsync and curl have the ability to resume failed transfers/copies. Noting that there can be many causes of these failures, in some cases the program can do "cleanup" ...
23
votes
10answers
21k views

How do I copy all files and directories, except certain ones over ssh?

Using the Linux command line, I use the scp command, to copy all the files and folders from a certain directory. However, I don't like to consume bandwidth, for copying things I rarely change like my ...
23
votes
1answer
6k views

Transfer a file over a unstable SSH connection

I'm trying to upload some big files (around 10GB) with a slow upload speed (200kb/s) on a often disconnected SSH connection (due to poor network conditions). I'm trying to use scp, but if there is a ...
23
votes
5answers
25k views

How do you compare two folders and copy the difference to a third folder?

You've got three folders: folder current, which contains your current files folder old, which contains an older version of the same files folder difference, which is just an empty folder How do you ...
22
votes
4answers
54k views

How can you move (or copy) all files of a certain type to a directory in Unix?

I'm not very familiar with all the tricks of grep/find/awk/xargs quite yet. I have some files matching a particular pattern, say *.xxx. These files are in random places throughout a certain directory....
22
votes
2answers
2k views

What happens when I kill 'cp'? Is it safe and does it have any consequences?

What are the consequences for a ext4 filesystem when I terminate a copying cp command by typing Ctrl + C while it is running? Does the filesystem get corrupted? Is the partition's space occupied by ...
21
votes
5answers
20k views

How can I copy a file and create the target directories at the same time?

I want to cp aaa/deep/sea/blob.psd to bbb/deep/sea/blob.psd How do I do the copy if the deep and sea directories don't exist under bbb so that the copy both creates the directories that are needed ...
21
votes
5answers
47k views

Duplicate file x times in command shell

I try to duplicate a video file x times from the command line by using a for loop, I've tried it like this, but it does not work: for i in {1..100}; do cp test.ogg echo "test$1.ogg"; done
21
votes
7answers
27k views

How to copy a folder structure and make symbolic links to files?

I have a folder SOURCE that contains several sub-level folders, each with its own files. I want to copy this folder in a new folder COPY where I need to copy the directory structure but keep the ...
20
votes
1answer
742 views

How to move a directory, file by file? (instead of “copy then remove”)

My computer has one 500GB drive. I want to move 400GB of data from /unencrypted to /encrypted. Both directories are on the same partition, but /encrypted is handled by ecryptfs, so mv /uncrypted/* /...
19
votes
2answers
7k views

What happens if a file is modified while you're copying it?

What is the effect of copying a file say fileA.big (900mb) from location B to locationC. If during that cp operation, say 35% through the process, fileA.big is appended with new information and grows ...
18
votes
1answer
38k views

Best way to sync files - copy only EXISTING files and only if NEWER than target

I'm doing this sync locally on Ubuntu 12.04. The files are generally small text files (code). I want to copy (preserving mtime stamp) from source directory to target but I only want to copy if the ...
17
votes
3answers
30k views

Copy and paste a file/directory from command line

Instead of using the following command: cp {source file} {dest file} I want to be able to copy a file into the clipboard, and paste it somewhere else, in another directory. something like this: ...
17
votes
1answer
9k views

Best way to continue stopped move (mv) by merging directories?

I have moved (mv) a pretty large directory on my NAS (Linux based), but had to interrupt the procedure. Not being a regular Linux user, I though I could just continue and merge the rest later in. mv /...
17
votes
3answers
3k views

How is install different from cp? [duplicate]

How is install different from a simple copy, cp or dd? I just compiled a little utility and want to add it to /usr/sbin so it becomes available via my PATH variable. Why use one vs the other?
16
votes
1answer
1k views

Approximating atomic move across file systems?

I have to move some files from one filesystem to another under Ubuntu. However, it is very important that the files never exist as partial or incomplete files at the destination, at least not under ...
15
votes
5answers
2k views

copy smallest files first?

I have a large directory containing subdirectories and files that I wish to copy recursively. Is there any way to tell cp that it should perform the copy operation in order of file size, so that the ...
15
votes
2answers
14k views

Problem with install command to copy a whole directory

So I have a repo with some of my config files and I'm trying to create a makefile to install them in the homedir. The problem I have is that when I run the following command straight in bash install -...
14
votes
3answers
28k 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.
14
votes
1answer
2k views

How to duplicate a file without copying its data with btrfs?

I have no experience with btrfs, but it's advertised to be able to de-duplicate files. In my application, I'd need to duplicate whole directory trees. From what I learned, btrfs only de-duplicates ...
13
votes
5answers
80k views

How can I get the address of my local machine?

I'm on a macbook running Lion. In Terminal I'm connected to my schools server with ssh. I navigated to a folder on the server and have a file I want to copy to my local machine, but I don't know what ...
13
votes
4answers
48k views

Execute command in sftp connection through script

This is a very basic question I am just quite new to bash and couldn't figure out how to do this. Googling unfortunately didn't get me anywhere. My goal is to connect with sftp to a server, upload a ...
13
votes
2answers
903 views

Timestamps of files copied to USB drive

I have a problem with the timestamps of files copied from my PC or laptop to USB drives: the last modification time of the original file and that of the copied file are different. Therefore, ...
13
votes
1answer
39k views

Copy a file and append a timestamp

I've got two issues with my script that copies files and adds a timestamp to the name. cp -ra /home/bpacheco/Test1 /home/bpacheco/Test2-$(date +"%m-%d-%y-%T") The above adds Test2 as the filename, ...
13
votes
5answers
19k views

How to clone/copy all file/directory attributes onto different file/directory?

I want to copy the attributes (ownership, group, ACL, extended attributes, etc.) of one directory to another but not the directory contents itself. This does not work: cp -v --attributes-only A B cp:...
12
votes
4answers
52k views

how to rename files while copying?

How would I copy (archive style where date isn't changed) all the files in a backup directory to the user's directory while renaming each file to remove the random string portion from the name (i.e., -...
12
votes
7answers
80k views

Downloading and uploading files via telnet session

I have an attendance device running Linux OS. I can connect this device via telnet session. There are some files in the device that I would like to download and upload with new files. How can I do ...
12
votes
1answer
522 views

How to copy all files in a folder excluding files which are being written?

I download multiple files to a folder downloading via HTTPie. A bash script aims to process downloaded files, and I tried to copy the downloaded files to another folder as find /folder/downloading -...
11
votes
5answers
11k views

How do I copy a file from multiple servers to my local system?

We have multiple deployment of an application on servers such as app00, app01 and so on. I need to copy a single log file from all these servers onto my local mac so I can perform some grepping and ...
11
votes
3answers
2k views

How to copy a directory which root can't access to a directory that only root can access?

I have a directory on an nfs mount, which on the server is at /home/myname/.rubies Root cannot access this directory: [mitchell.usher@server ~]$ stat /home/mitchell.usher/.rubies File: `/home/...
11
votes
5answers
33k views

How to copy symlinks as symlinks from one machine to another?

Let's assume I have two identical systems. On the first system I've created a symbolic link. On the second one I want to copy that symlink via sftp and the symlink shall work the same (i.e if the ...
11
votes
5answers
10k 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 ...