cp - Command-line tool to copy a file

learn more… | top users | synonyms

0
votes
2answers
40 views

How can I copy a hidden directory recursively and preserving its permissions?

mkdir backupcache cp -rp .cache backupcache # or cp -rp \.cache backupcache does not work nothing gets copied and directory backupcache remains empty
11
votes
3answers
72k views

How to copy a file from remote server to local machine?

In my terminal shell, I ssh'ed into a remote server, and I cd to the directory I want. Now in this directory, there is a file called table that I want to copy to my local machine /home/me/Desktop. How ...
1
vote
1answer
30 views

Why does size increase after I copy?

I'm copying a directory from one mount point to another, yet I see a size increase between the two and I'm wondering why that is. My first mount point is named /home/directory/mount1, and inside it ...
3
votes
2answers
36 views

How to copy just timestamps, or “I should have used cp -p”

I foolishly copied a very large amount of data using cp -r. Looking at it now, I've realized that this means I lost my file modification times. I should have used cp -rp. My directory structure and ...
95
votes
10answers
112k views

Is it possible to see cp speed and percent copied?

I'm having problems when copying large files using nautilus (it gets stuck). I need to copy, using cp. I would like to know if there are any parameters that shows the % copied and also the transfer ...
1
vote
1answer
56 views

copy huge number of files into date structured directory order

I need to copy around 40.0000 files into date structured folders. example file: /var/public/voicelogging/quality_monitoring/20151209/bbbbbb_I_20151209-185841_xxxxxx_12434_89343.WAV Is one of the ...
2
votes
2answers
959 views

Is there a --parents option for mv like for cp?

cp has a useful feature --parents that allows a file's directory structure to be copied to another directory: $ cp -v --parents source/directory/from target/ ‘source/directory/from’ -> ...
1
vote
0answers
24 views

Copies to NFS server write to mount point, not to mounted drive

I have a drive mounted at /home/ftpuser/uploads, and the /home/ftpuser folder is also exported via NFS. FTP uploads to the uploads folder work as intended. If I unmount the drive, the files disappear, ...
4
votes
2answers
863 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 ...
1
vote
4answers
3k views

How do I suppress error messages from cp?

I am currently looking ways to suppress error command in Linux, in particular, the command cp. I do: root@ubuntu:~$ cp /srv/ftp/201*/wha*/*.jj ~/. cp: cannot stat `/srv/ftp/201*/wha*/*.jj': No ...
-2
votes
2answers
84 views

Print out a log file with error from a cp command

I am writing an sh file I have this command cp test/*.txt NewDirectory/ from my understanding it will go one by one in the test folder 1.txt 2.txt 5.txt 6.txt but won't copy 3.txt 4.txt ...
17
votes
6answers
60k views

How to append date to backup file

I need to make a backup of a file, and I would like to have a timestamp as part of the name to make it easier to differentiate. How would you inject the current date into a copy command? ...
0
votes
2answers
181 views

cp: cannot create directory 'ABC.DEF/G/H': Structure needs cleaning

What does it mean "Structure needs cleaning" ? I've never seen such error code before - and man cp is not that helpful. It has happened to me on ext4. I was trying to copy directory using: cp -arv ...
1
vote
1answer
42 views

cp vs. mv: which operation is more efficient?

I find myself moving reasonably large amount of data (20+ GB) from one directory tree to other. Often times they are on the same filesystem but sometimes they are on different ones. I do cp just to ...
7
votes
2answers
2k views

Is there a difference between hardlinking with cp -l or ln?

I am implementing a backup scheme using rsync and hardlinks. I know I can use link-dest with rsync to do the hardlinks, but I saw mention of using "cp -l" before "link-dest" was implemented in rsync. ...
1
vote
2answers
640 views

How use minimum number of commands to copy all .txt files from all subdirectories to one directory?

I have more than 90 subdirectories and inside each one, there will be a number of .txt files. What I need to do is to copy all those txt files out to one single directory. How can I do that?
0
votes
2answers
25 views

Command which that isn't in norm

I have this example cp `which mv` rename In instruction of my homework is, that this command isn't in norm and replace the command with different example that does do exactly the same. My question ...
0
votes
2answers
33 views

Does cp -a refresh existing files, overwrite or skip

If I use cp in archive mode e.g cp -a /my_old_directory/* /new_location/my_new_directory/ to replicate a directory structure and all that is in it. If I then run the same command again will any ...
1
vote
1answer
35 views

What metadata of a file does cp preserve by default?

By default, what file metadata does cp preserve, and what file metadata not? For example, if I am correct, the mtime is changed, the access list is preserved, and I would to know about the other ...
-1
votes
3answers
35 views

changing permission after copy the directory? [closed]

I have two directory in two different path there are some common subdirectories and files between them I want to copy the content of first directory to the second one meanwhile I need the same ...
3
votes
1answer
89 views

Syntactic differences in cp -r and how to overcome them

Let's say we are in a blank directory. Then, the following commands: mkdir dir1 cp -r dir1 dir2 Yield two (blank) directories, dir1 and dir2, where dir2 has been created as a copy of dir1. ...
1
vote
2answers
39 views

Copy/move group files with renaming

I want to copy (or move) some files like cp ./patt*.py /other/path. However /other/path/ already contents files with the same names. So, I would like copy with renaming (adding some suffix, for ...
32
votes
11answers
55k views

How to check progress of running cp?

Is it possible to check the progress of running cp process? Some processes respond to various KILL signals so that you can check what is their status. I know that I can run cp with parameter -v but ...
3
votes
2answers
431 views

Alternate solution for making multiple copies of a single file using command line?

I am trying to copy a file to 10 files. Say for example I have a E-mail message named test1.eml. I want 10 copies of the same file. When I searched in internet, I came across this stackoverflow ...
4
votes
3answers
34k views

Copy only regular files from one directory to another

I'd like to copy a content of directory 1 to directory 2. However, I'd like to only copy files (and not directories) from my directory 1. How can I do that ? cp dir1/* dir2/* then I still have the ...
10
votes
2answers
18k views

rsync is very slow (factor 8 to 10) compared to cp on copying files from nfs-share to local dir

I have a freshly installed Ubuntu-server which is ought to be the new backup-server for our VM-storage. The server has 4 nics, 2 of them 10Gbit (in fact an intel x540-T2 with the newest driver ...
3
votes
3answers
107 views

How to use cp -u on a Solaris system which does not support the -u option?

I am new in here. I am facing problem in Solaris system.I want to copy only when the SOURCE file is newer than the destination file or when the destination file is missing. As you know, this feature ...
0
votes
1answer
61 views

How can I succesfully call the execv function? [closed]

I am trying to make a program that will copy file1 into file2 the following way: cp -i -p file1 file2 Now I call my executable copy and so by calling copy file1 file2 It will do the same thing ...
0
votes
1answer
86 views

cp doesn't work in a script but does from the command line

I have this script for automating a simple process where I scan a number into the command line, grep that number out of a catalog file which gives me a path, and then copy the DVD which the above ...
-1
votes
1answer
97 views

Copy a hidden file to a directory?

I'm trying to copy all of the hidden files to a directory. The problem is I can't copy it into a new folder. I get Permission denied error. How do I fix this? I used: cp -rf /usr/include /cse220-p01 ...
10
votes
1answer
16k views

Unzip file contents, but without creating archive folder

I have a file myarchive.zip that contains many directories, files, etc. Let's say this myarchive.zip file lives in a directory called "b". Well, when I use the "unzip myarchive.zip" command, the ...
0
votes
0answers
20 views

Will exiting SSH session cancel CP? [duplicate]

I have SSHed onto a CentOS server and initiated a CP from one directory on the server, to another directory on the server. If I exit my session, will the CP cancel? If so, is there a way to exit the ...
-2
votes
1answer
67 views

What does the -p option do exactly with the cp command?

So I am trying to understand what is the significance of the -p option for the cp command. I opened the manual of the cp command and it says -p same as --preserve=mode,ownership,time stamps. But ...
-2
votes
3answers
140 views

What does `cp -x` do?

I know in the man pages it puts it as -x, --one-file-system stay on this file system but can someone explain it to me like I'm five.
4
votes
2answers
529 views

How to wait for the copying process (cp) to finish?

I want my RPi 2 (with MiniBian (a minimal version of Debian-based Raspbian OS) as its OS) to execute a script when it detects a USB flash memory is inserted. So this is what I have done: I created ...
1
vote
1answer
246 views

Why can't I copy symbolic links?

cp: cannot create symbolic link ‘/xyz/pdq’: Operation not permitted So, I'm trying to copy one directory to a Veracrypt encrypted USB stick. Command I used was: cp -aL /source /destination I've ...
1
vote
1answer
38 views

Is it possible to overwrite a directory with a file in linux

Can someone please help me with a possible case of accidental deletion on a linux box? I ran the following command: cp file1 /newdir1/folder1 What I intended to do was to copy file1 to the ...
2
votes
2answers
48 views

Is it possible to display a running timer in a shell script while copying a directory?

So I have a shell script that basicly backs up one server to another server. In the process I have to cp a very large directory (140GB) to another location, in the shell script I would love to have ...
2
votes
0answers
152 views

Copy file if no error was encountered, else delete copied portion

I am copying a folder in Linux with plenty of files. Some of the files give me errors like this: Error splicing file: Input/output error The problem is that it keeps the file in the new location ...
7
votes
3answers
70 views

How to prevent cp from merging two identically-named directories?

I have two identically-named directories: $ ls mydir file1 file2 $ ls other/mydir file3 file4 If I copy mydir to other, the two mydirs get merged: $ cp -r mydir other $ ls other/mydir file1 ...
10
votes
1answer
127 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 ...
25
votes
2answers
56k 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
1answer
334 views

Cp with full renamed path in execl c program

I need to copy file and rename it in execl function so i did: if ( fileExists(new_dest) ){ /*function in which i rename the file by gtk dialog*/ renameDialog(fileName); ...
3
votes
5answers
125 views

What are some quick ways of making N copies of a particular file?

Say, if I wanted to make N copies of a.txt, and wanted them to be numbered a1.txt, a2.txt, a3.txt, etc... How would I do such a thing succinctly?
30
votes
11answers
40k 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 ...
0
votes
1answer
81 views

Cron to find exec cp and redirect output with time / date per line?

I try to setup a cron task to run a set of basic shell commands. I need to look to any files created on the last day, then copy to another folder and generate a log stating, line by line, the date ...
2
votes
1answer
139 views

How to copy recursively all files not older than 1 day?

How to copy recursively all files not older than 1 day? I first tried find . -amin -1440 | xargs cp /dest But it doesn't work because the items given to xargs should be positionned before the ...
1
vote
2answers
101 views

Combine xargs -I with sed

I want to use find to find certain files and then use xargs with cp and sed to move these files to another folder and rename them. I know how to do this in a loop, but that is not what I am looking ...