Questions tagged [file-copy]

Questions regarding copying files from one place to another

Filter by
Sorted by
Tagged with
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 ...
11
votes
5answers
32k 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 ...
10
votes
5answers
1k views

Moving millions of files to a different directory with specfic name patterns

I have millions of files with the following nomenclature on a Linux machine: 1559704165_a1ac6f55fef555ee.jpg The first 10 digits are timestamp and the ones followed by a _ are specific ids. I want ...
1
vote
0answers
11 views

Why two folders with the same contents have different sizes? [duplicate]

I just created a copy of my music library, let's call it music_backup, and also have the original folder, called music. The backup folder was created using the trusted rsync, so no weird tools ...
1
vote
1answer
1k views

Getting error while using sftp (get: Invalid Flag -r)

I want to copy a few folders from Server A (/aaa/bbb/ccc/) to Server B (/xxx/yyy/zzz/), considering Server A is source and Server B is destination. There are multiple folders in ccc/ which need to be ...
3
votes
4answers
262 views

gzip compress a local folder and extract it to remote server

I am new to these commands. I am trying to gzip a local folder and unzip the same on the remote server. The thing is, gzipping and unzip must happen on the fly. I tried many and one of the closest I ...
3
votes
1answer
4k views

rsync + renaming the copied files

Is it possible to change the name of the destination file (add some timestamp as a prefix) when copy is done by rsync ? For example, I can use the following command to change the name of the ...
55
votes
5answers
74k 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 ...
0
votes
1answer
37 views

copy paste from debian buster doesn't work on MS-Windows 10

I have been working on a computer which apparently has Debian buster as well as MS-Windows 10 1903 . On the said machine before you could copy and paste files and folders without an issue. In some ...
1
vote
1answer
25 views

Rsync stuck in D state

I'm moving about 1 TB data from an EBS mounted on my EC2 to another EFS mounted on the same instance. I've been able to copy about 840 GB of data using rsync within the past 2 weeks or so. Now when I'...
4
votes
3answers
1k views

Recursive copy files with rename

If I have input folder files_input that has subfilders like 01-2015, 02-2015, 03-2015 etc and all these subfolders have other subfolders. Each subfolder has only one file called index.html. How can ...
0
votes
1answer
28 views

copy-merge several folders contents, prioritizing newer files

I have few folders like this with their contents data/ -2011/ ---images/ ------logo.jpg ------banner.jpg ---reports/ ------monthly.pdf -2012/ ---images/ ------logo.jpg ---reports/ ------monthly.pdf -...
13
votes
4answers
46k 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 ...
644
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 ...
10
votes
2answers
2k views

Why are there no file insertion syscalls

To my understanding, for manipulating files there is only the sys_write syscall in Linux, which overwrites the file content (or extends it, if at the end). Why are there no syscalls for inserting or ...
0
votes
1answer
60 views

cp command saying directory does not exist when it does [duplicate]

I'm writing a bash script and in it I'm doing something like the following: #!/bin/sh read -p "Enter target directory: " target_dir cp some/file.txt $target_dir/exists/for/sure/ When I run this ...
0
votes
5answers
87 views

Special “copy and rename” case

I have a deeply nested folder structure in which there are hundreds of files called data.log. I need a script to rename each of these data.log files according to the name of the parent folder they are ...
8
votes
2answers
5k views

How to get the Samsung Galaxy S5 to work with MTP on Debian 9?

So I'm trying to share files between the Samsung Galaxy S5 with Android and my Debian 9.1 with KDE machine. The problem is that I keep getting: The process for the mtp protocol died unexpectedly. ...
0
votes
1answer
346 views

How to use rsync to force all *.jar files to match?

I have a directory with many files in it. The only ones I care about are those with the extension .jar. However, there are other files in the directory as well. I have a source directory with only ....
1
vote
1answer
135 views

Pipe data onto another machine with nologin

I have a huge directory I want to copy to another machine as a .tar.gz file. I don't have a lot of space on either machine, so I'd like to copy the file through a pipe, like this: tar -czf - ...
4
votes
1answer
85 views

Move/copy millions of images from Macos to external drive to ubuntu server

I have created a dataset of millions (>15M, so far) of images for a machine-learning project, taking up over 500GB of storage. I created them on my Macbook Pro but want to get them to our DGX1 (GPU ...
0
votes
2answers
3k views

copy files from multiple sub-directories to the same destination directory

I have something a directory like this Main Directory SubDirectory SubsubDirectory1 xx.jpg xx,jpg SubsubDirectory2 xx.jpg xx,jpg ...
0
votes
0answers
9 views

Can the USB subsystem copy only one file at a time?

Xubuntu 18.04 up-to-date $ uname -a Linux haggis 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux In one session, I'm copying a lot of files from a LV with ...
2
votes
1answer
42 views

How to write a script to move files with a specific name from folder “A” to folder “B” in my Google drive?

How can I write a script that moves files with a certain name from a certain folder to another certain folder in my Google drive? Example: I have a folder named 'A' with three files named 'X', 'Y', ...
0
votes
2answers
65 views

Copying files based on partial names in a file

I have millions of xml files in a folder. The name of the files follow a specific pattern: ABC_20190101011030931_6049414.xml In this I am interested only in the last set of digits before xml ...
0
votes
3answers
479 views

Is there a `cp` like command for verifying data and removing files?

I have some photo files on my phone, and I am backing them up to an external drive. (Everything is mounted on a linux laptop.) I have copied the files, when I should really have mv'ed them. However, ...
5
votes
1answer
498 views

systemd and copy (/bin/cp): no such file or directory

While manually copying the file the following works, as below: userx@x:~$ cp -rv /opt/test-bak/* /opt/test/ '/opt/test-bak/file1' -> '/opt/test/file1' '/opt/test-bak/file2' -> '/opt/test/file2' ...
100
votes
4answers
127k views

How to copy-merge two directories? [duplicate]

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 /...
0
votes
1answer
42 views

Copy files from folders and sub folders without preserving directory structure

I have a folder(A) which is structured like this Main Directory(A) | | Subdir------Subdir2-----Subdir3 | | | | | |...
0
votes
1answer
152 views

Finding files and copy with folder structure intact

I am searching files who have either been created or modified for the last 60 minuts. I find these via find ~/data/ -cmin -60 -mmin -60 -type f ~ the home directory /usr/wg/ After that I want to ...
0
votes
2answers
44 views

Copy folder to multiple (similar) locations simultaneously

I have around 90 websites I need a plugin installed on (wordpress) and I was wondering if there's a way to copy the plugin folder to all of them in a single run (i.e., simultaneously / in parallel).  ...
0
votes
1answer
2k views

How to copy files nested in directories that match a pattern?

I'm looking to copy files from subdirectories that match this pattern vendor/plugin/*/tasks/*.rake into a folder lib/tasks
2
votes
2answers
9k views

Is it possible to use dd to clone only the part of the hard drive which is used?

if only 1/3 of a 300GB hard disk is used. Is it possible to use dd to clone the drive (but only the 100GB that is used)? dd if=/dev/sda of=clone.img
5
votes
1answer
254 views

In what order does sftp fetch files when using “get -r folder”?

I'm doing a file transfer using sftp. Using the get -r folder command, I'm surprised about the order that the program is downloading the content. It looks like it would be selecting the files it ...
2
votes
4answers
297 views

How to copy the rest of lines of a file to another file [duplicate]

I have the string xyz which is a line in file1.txt, I want to copy all the lines after xyz in file1.txt to a new file file2.txt. How can I achieve this? I know about cat command. But how to specify ...
0
votes
3answers
89 views

How to copy an image from one directory to another in unix?

Okay so for a research project, I am charged with working on a digital video game that happens to be formed by the use of Unix and emacs (don't know if they are the same thing because I just started ...
1
vote
2answers
300 views

cp --reflink=auto for MacOS X

cp --reflink=auto shows following output for MacOS: cp: illegal option -- - Is copy-on-write or deduplication supported for HFS? How can I COW huge files with HFS?
0
votes
1answer
34 views

Copy or move large file with transient name till the file is completely transfered to destination in linux

I am trying to copy/move a large file (15 GB) to a directory in Linux and want to have a dependency on that event. Now lets say I have a file named abc.txt, and I am running below command: mv /usr/...
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 ...
0
votes
1answer
52 views

How to resolve btrfs errors? copying from btrfs to another partition?

I had a working system that was running out of space. So I added space to the end of the disk. Boot from gparted ISO launched gparted moved partition 3 of 3 to the right. Went to resize partition ...
0
votes
0answers
36 views

Linux | Copy open files to a different directory and keep them Synchronized

I want to copy files while they are in use by an application to a separate directory on my Ubuntu system. These files in the source directory should be in continuous synchronization with their copies ...
57
votes
3answers
43k 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-...
1
vote
2answers
21 views

Get filepath of every file that's copied from one folder to another

I am using Ubuntu 18.04 LTS and I wish to copy files from one folder to another and along with it also wish to store the filepath of each file that's being copied from folder1 to folder2 in a third ...
4
votes
4answers
4k views

Copy only certain file types from a folder structure to another

I have a top folder with many sub-folders. It's named "a". There are many .png and .jpg files in there. I'd like to recursively copy "a" into a new folder "b", but only copy the .png and .jpg files. ...
5
votes
1answer
496 views

What happens when you rsync without a destination path? [duplicate]

I copied a file to destination without providing the path. It seems to have copied successfully, but i cant find the file in the destination, where could it be located? rsync -av --progress file.txt ...
0
votes
3answers
74 views

Copy a file in a destination folder

I have a file in a very long path, for example: /opt/very/long/path/file1 I want to copy the file in this directory: cp /opt/very/long/path/file1 /opt/very/long/path/file2 I don't want repeat this ...
0
votes
3answers
88 views

How to find the first X gb of data?

I've been trying to find a way to free up some space on a drive by moving folders to another. I have a folder full of stuff I can move, doesn't need to be all of it, to free up some space. In Windows ...
0
votes
1answer
65 views

Create folders from space-delimited filenames and copy files into them

I'm currently trying to organize several thousand files which are named according to what's in them, and the various "tags," if you will, are separated by spaces. So, for example: foo_bar bar_foo.txt ...
18
votes
5answers
45k 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
2
votes
1answer
272 views

rsync keeps previous partial file when resuming

I often transfer large files from a remote server using rsync with the following command : rsync -rvhm \ --progress \ --size-only \ --stats \ --partial-dir=.rsync-partial \ "user@...