cp - Command-line tool to copy a file

learn more… | top users | synonyms

1
vote
2answers
134 views

How to emulate 'cp -a' on Solaris which does not have it?

How to do a cp -a on a Solaris system which does not support the -a option?
1
vote
2answers
625 views

How can i keep the mtime of files and directories when I use rsync or cp? For use in Backup/Incremental Backup

I have a new NAS box and after looking through numerous backup solutions I've found doing it manually through PuTTy to work the best. After logging in to the box through PuTTy as root, I first need ...
0
votes
1answer
467 views

Is there a way of copying only directories and not files? [closed]

I want to copy only directories from a folder on a remote server to my server. Is that possible? Here is the code I have so far but it copies files and folders: scp -rq username@192.168.78.331:/copy/...
3
votes
2answers
97 views

POSIX description of cp -R

I just became really confused by the implementation of bash's cp -R command compared to how POSIX words what should happen Given the posix definition, I would expect cp -R srcDir existingDestDir to ...
0
votes
2answers
27 views

Search by pattern, and copy within the same folder but with a different name

This is the folder structure: /home/user/Pictures/Vacation/Italy/Rome/photo.front.001.jpg Within the folder Rome I have many other photos, but I'm only interested in the ones that have "front" in ...
23
votes
4answers
29k views

Using rsync to move (not copy) files between directories?

I have been using rsync to copy files for some time. My understanding is that rsync is faster than cp when some of the files to transfer are already in the destination directory, transferring only the ...
1
vote
2answers
69 views

Copy files that are created today without FIND command and SFTP to another server

I have a directory with 'n' number of files in it. I am trying to write a shell script which will list only the files created on the particular day the script is running, and will use sftp to move the ...
1
vote
3answers
99 views

Copy command with command line arguments

I am writing a simple script which will take a keyword. Then, it will look for files in the directory which contain that keyword and copy them to another directory (name of directory = keyword). The ...
21
votes
4answers
1k views

What is the added value of the -T option in GNU cp and mv?

Why do some GNU Coreutils commands have the -T/--no-target-directory option? It seems like everything that it does can be achieved using the semantics of the . (self dot) in a traditional Unix ...
2
votes
1answer
38 views

SCP selectively from directory and subdirectory

I don't know if this possible but I wanted to check with all UNIX geeks here. We have a directory structure as follows: Subject_11 -subdir01 -subdir02 -subdir03 -subdir04 Now I want to scp ...
1
vote
1answer
328 views

Copying wallpaper images into a single folder

In my ubuntu 12.04 set-up, there are lots of wallpaper images in the directory /usr/share/wallpapers. For example, one might be usr/share/wallpapers/Leafs_Labyrinth/contents/images/1600x1200.jpg ...
4
votes
2answers
1k 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 ...
2
votes
1answer
37 views

Recursive move (`mv -rn`, like `cp -rn`), a move that will only move not present files

Context I have user uploaded content that needs to be backed up. The content is over 3 separate servers at /var/www/domain/media/ (on each server it is in the same place). The backup is a NFS ...
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. ...
0
votes
2answers
45 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
13
votes
3answers
87k 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
36 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
39 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 ...
96
votes
10answers
118k 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
62 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
1k 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’ -> ‘target/...
1
vote
0answers
28 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, ...
1
vote
4answers
4k 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
130 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 ...
19
votes
6answers
64k 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? [root@...
0
votes
2answers
389 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
49 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 ...
1
vote
2answers
691 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
38 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
44 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
38 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
92 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
41 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
57k 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
36k 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
19k 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
114 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
74 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
97 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
108 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
17k 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
83 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
174 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
607 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
412 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 ...