cp - Command-line tool to copy a file

learn more… | top users | synonyms

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 ...
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 ...
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
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 ...
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 ...
0
votes
2answers
46 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
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 ...
1
vote
1answer
63 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 ...
1
vote
0answers
29 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
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 ...
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 ...
0
votes
2answers
397 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
45 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 ...
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 ...
-3
votes
2answers
115 views
-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 ...
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 ...
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
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 ...
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 ...
-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
176 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
612 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
421 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 pre-...
2
votes
2answers
54 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 ...
7
votes
3answers
72 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
147 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 ...
0
votes
1answer
372 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); printf("%s\n",...
2
votes
1answer
147 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 /...
0
votes
1answer
87 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 ...
1
vote
2answers
116 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 ...
1
vote
0answers
71 views

Live OS freezes while copying files

I was trying to backup many files (~10,000) from a hard drive on an OS-less notebook to an external 500 GB HDD, so I booted up the Fedora 22 Live XFCE spin using a USB, started the copy and after 5 ...
0
votes
0answers
39 views

`cp -iprv` from UFS to NTFS panics FreeBSD and reboots

My nas4free OS seems to be dead, so I mounted its 2GB UFS data partition on my FreeBSD machine, and my 1TB external USB NTFS HDD (using ntfs-3g /source /mnt/dest). I tried the casual cp -iprv /SOURCE /...
3
votes
1answer
43 views

cp command which partially resolves symlinks

Is there an easy way to copy a directory recursively where symlinks to external files/directories are resolved (target file is copied), but internal symlinks (pointing to files inside the copied tree) ...
3
votes
1answer
58 views

OpenBSD: Move directories larger than X to new directory

I'm accessing OpenBSD via SSH and I'm wanting to create a command to find directories larger than 20MB and copy them to a new directory, keeping all folder structure. So far I have this: find /...
0
votes
2answers
252 views

Copy a full folder to another location on the same server

I would like to make a backup of a WordPress uploads folder from a a master site to a development site. I thought I would give this code a try: cp -urp /home/my_site/public_html/wp-content/uploads/* ...
0
votes
1answer
43 views

FreeBSD 9.3 and OSX color tags

I am using nas4Free 9.3.2 and FreeBSD 9.3-RELEASE-p22. I noticed after using cp, that my moved files no longer had the color coded labels I had applied in OSX. Share mounted in AFP. To test this, I ...
4
votes
1answer
55 views

How to ensure proper file permissions when running installer bash as sudo?

I am making a installer bash, playing with it a little too. But I just came across a serious problem: As I run the bash with sudo ./install.sh, all the files it copies are owned by root and therefore ...
0
votes
1answer
330 views

Copy all files matching criteria on find command with -exec

Below are my attempts at copying all files except .out and .class files into a subdirectory titled homework21/. Note homework21 is a subdirectory of the folder in which I am working in. me@ice4:~/...
18
votes
2answers
2k views

What is the difference between * and *.* while copying?

What is the difference between following 2 commands? cp -rp /dir1/*.* /dir2/ cp -rp /dir1/* /dir2/
-2
votes
3answers
541 views

Understanding permissions properly for cp [duplicate]

I am trying to understand the permission usage for the cp command in unix. What are the permissions required for copying a file into a directory What are the permissions required for copying out of ...
-2
votes
1answer
89 views

Error while trying to copy file to many files using cp [closed]

Error when running this command, I think the command is clear to get the idea. cp file.txt /folder/*/*/*/file.txt I found out cp dosen't support *, so how can I do the same thing in bash or command-...
1
vote
1answer
621 views

Text file busy when I copy some files

I have this error when I want to copy some files My command: cp -rf /sasech/xgedff/pur/liv/v15h30050-DLIV0177521/dmesa/bin/* /applis/rgedff/pur/bin Results: cp: /applis/rgedff/pur/bin/../bin/lib/...