3
votes
5answers
631 views

How can a filesystem be copied exactly as is?

I have a file system for a device I am programming that I would like to make an exact copy of. Ideally I would like this copy to be identical to the folder that it was copied from. I have tried using ...
3
votes
2answers
202 views

cp -L vs. cp -H

Problem When copying files with cp -H or cp -L, I get the same results: $ ls -l fileA fileA -> fileB $ cp fileA somewhere/ -H $ ls -l somewhere/ fileA # fileA is a copy of fileB, only ...
4
votes
3answers
2k views

convert soft- to hardlinks with cp

The cp command's infopage offers on the option --preserve= the following: links Preserve in the destination files any links between corresponding source files. Note that with -L' ...
3
votes
1answer
110 views

cp --attributes-only documented but not working “now”?

PROBLEM: cp --attributes-only Source Target results in two files unchanged, where the attributes from Source should be copied to Target. Attempts to solve: As I have the 8.13 version of coreutils ...
14
votes
4answers
939 views

Why not always use rsync?

I wanted to ask is there any reason not to use rsync for everything and abandon cp? I wasn't aware of rsync and now I don't know why cp is ever needed.
2
votes
1answer
69 views

Why don't I see a file being copied right away with ls?

Is it due to the buffering in memory? I did cp /network/large_file . & and I kept doing ls -lh to monitor progress, but the file didn't appear until it was about 400MB. Linux 2.6 kernel, Bash 4, ...
3
votes
5answers
3k views

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 using: cp ...
0
votes
0answers
21 views

file modified while doing scp/cp [duplicate]

I'm doing scp to a database while it's active. Its not very critical but I would like to know what will happen to a file when it is modified in the middle of a cp process? Does it get corrupted or it ...
0
votes
4answers
124 views

concatenating multiple files with multiple headers

Im trying to concatenate multiple files with multiple headers to have one file with all the information in it for example. File 1: Numbers 1 2 3 Letters A B C File 2: Numbers 4 5 6 Letters D E ...
2
votes
1answer
754 views

Copying a working Linux instead of installing a new one [duplicate]

It is possible to move an installed Linux from one drive to another or from one disk to another by two methods: dd command which copies sector by sector including boot sector cp command, and then ...
10
votes
3answers
3k views

How does “cp” handle open files?

I'm having two separate directories. The user loads a file into the first. Theres a cronjob running in the background which copies the files every 5 minutes over to the second directory. What happens ...
4
votes
2answers
3k views

Difference between cp -r and cp -a

Looking for the difference between cp -r and cp -a? What does recursive mean in terms of copying files from a folder?
0
votes
3answers
2k views

How do I cp the folder, not just the folder content?

Let's say I have folder structure like this: /parentFolder/ folder1/ folder1.1/ file1 folder2/ file2 How do I copy folder2 inside folder1.1 so that file2 is also in ...
2
votes
2answers
3k views

How can I selectively copy files from one directory to another directory?

On Linux, how do I selectively copy most – but not all – files from a directory (dir1) to another directory (dir2)? I do not want to copy *.c and *.txt files to dir2. The cp man page ...
27
votes
4answers
11k views

Difference Between cp -r and cp -R (copy command)

cp- r is meant to copy files recursively, and cp -R for copying directories recursively. But I've checked, and both appear to copy both files and directories, the same thing. So, what's the difference ...
1
vote
2answers
1k views

Is there a BASH command for copying all files from a directory tree and putting all the files in a single directory?

I have a ton of notes categorized into folders, but I think it might be better to put them all into one folder instead. Is there an easy way to do that?
10
votes
3answers
6k views

copy recursively except hidden directory

How do I copy recursively like cp -rf *, but excluding hidden directories (directories starting with .) and their contents?