cp - Command-line tool to copy a file

learn more… | top users | synonyms

0
votes
0answers
21 views

cp error “usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file” [closed]

Whenever I do cp -Rf /Users/gideonmorrow/Public /Users/gideonmorrow/Google Drive/Computer Backup/Users/gideonmorrow/Public/ it gives a error saying usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] ...
0
votes
0answers
19 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
2answers
86 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
32 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
71 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
274 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
62 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
35 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
38 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
66 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 ...
8
votes
1answer
81 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
104 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); ...
2
votes
1answer
115 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
55 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
59 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
39 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
31 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
32 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
41 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
70 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
41 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 ...
3
votes
1answer
44 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
129 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. ...
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
117 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
57 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 ...
1
vote
1answer
122 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: ...
2
votes
0answers
25 views

Files appear in a different timezone after transferring to another computer (even though both computers have same timezone) [closed]

I copied some files from an Archlinux computer to an Ubuntu one, but the time on the files after being moved showed as exactly 2 hours earlier than on the computer they were originally. (2 hours I'm ...
2
votes
1answer
28 views

Copying directories unrelated file names

Apologies for the dumb question. I'm trying to copy directories of data sets that pertain to the a certain case but the data sets are currently stored in different directories and with different (non ...
27
votes
6answers
986 views

How to copy a folder recursively in an idempotent way using cp?

When I use cp -R inputFolder outputFolder the result is context-dependent: if outputFolder does not exist, it will be created, and the cloned folder path will be outputFolder. if outputFolder ...
17
votes
5answers
1k views

Why use diff/patch when it is easier to just use cp

diff -u file1.txt file2.txt > patchfile creates a patch file which consists of instruction for patch to convert file1.txt to be exactly like file2.txt As the title says, Can't this be done using ...
-1
votes
2answers
40 views

Is there a variant of the “cp -a” command that avoids copying from other filesystems?

Let's say I have a directory /data/something with the following subdirs: /data/something/iowa /data/something/wyoming /data/something/burkinafaso /data/something/slovenia All four subdirs have ...
20
votes
4answers
989 views

Surprised by behavior of cp with hardlinks

I understand the notion of hardlinks very well, and have read the man pages for basic tools like cp --- and even the recent POSIX specs --- a number of times. Still I was surprised to observe the ...
1
vote
1answer
66 views

Folder permissions with cp --parents doesn't allow to copy another file

Scenario: with a script run by a normal user I want to copy several files, and replicate the dir structure. For example: cp --parents /lib/libacl.so /tmp/my_root/ cp --parents /lib/libc.so.6 ...
1
vote
2answers
179 views

What command should I use to move these particular elements?

Here is my initial situation: In a folder named for example Father, are stored some files in the following way: Father contains 24 children folders (let's call them Child1, Child2, ...), and each one ...
0
votes
1answer
68 views

How to backup all the files that I'm copying before being overwritten?

I have a folder like this: ./folder-a/index.html ./folder-b/index.html ./folder-c/subdir/index.html ./new-content/folder-a/index.html ./new-content/folder-b/index.html ...
1
vote
3answers
107 views

What is the output of “du” command during a long copy?

Recently, I launched the cp command to create a backup of a big directory. So, I used a command like this: cp -rv big_directory new_location Because the files are big, it took a long time to ...
-1
votes
1answer
157 views

Argument list too long with just 5000 files [duplicate]

I have a folder with 5000 files that I want to copy somewhere else. When I do cp ../folder* ., I get the following error: -bash: /bin/cp: Argument list too long However, getconf ARG_MAX returns ...
0
votes
2answers
815 views

How to use cp command in bash script to copy files with spaces ans $ characters in it? [duplicate]

I am trying to copy some files with spaces and $, @ symbols in their file names in a bash script but the script fails to copy the files stating it cannot find the file. I can see that it is treating ...
0
votes
1answer
32 views

Folder organization

I have several folders ("amazon", "niger", "rhine",...). Inside each of them I have several subfolders ("gfdl", "hadgem", "ipsl",...). Each subfolders is composed by 5 subfolders (e.g. in "amazon", ...
6
votes
1answer
388 views

Why does “cp -R --reflink=always” perform a standard copy on a btrfs filesystem?

Btrfs support Copy-On-Write. I tried to use that feature to clone a directory: cp -R --reflink=always foo_directory foo_directory.mirror I expected the command to finish almost instantly (like a ...
0
votes
0answers
11 views

csp where both source and destination are local or how to make cp show a progress bar [duplicate]

csp shows a nice progress bar when copying a file to/from a remote host. Since cp doesn't have such a nicety, it ocurred to me that I could use scp to copy files in the same machine (no remote host), ...
2
votes
3answers
930 views

How to copy and add prefix to file names in one step?

I want to copy and rename multiple c source files in a directory. I can copy like this: $ cp *.c $OTHERDIR But I want to give a prefix to all the file names: file.c --> old#file.c How can I ...
13
votes
3answers
602 views

How is install different from cp?

How is install different from a simple copy, cp or dd? I just compiled a little utility and want to add it to /usr/sbin so it becomes available via my PATH variable. Why use one vs the other?
1
vote
2answers
68 views

Randomly copy certain amount of certain file type from one directory into another

Sometimes I have a folder full of jpg's and I need to randomly choose 8 or so of them. How could I automate this so my account randomly chooses 8 jpg's from the folder and copies them to another ...
4
votes
3answers
324 views

How to copy recursively and change file names to be unique

I have a large tree containing a lot of photos on an external drive that was formatted with one of the linux filesystem types (don't remember which one). It's mounted on my mac and I'm trying to copy ...
5
votes
2answers
151 views

`sudo cp -a` changes ownership to root (instead of preserving the original user)

I was trying to backup some directories and some of the copies made by sudo cp -av resulted in being owned by root while others preserved their attributes. Is this a known issue or am I missing ...
1
vote
1answer
113 views

What is the actual process name when nautilus is copying files?

I am copying some files from an external drive to my desktop running Ubuntu. I can see the "File Operations" dialog which shows copying process. How do I find this particular process in ps aux | grep ...
0
votes
1answer
38 views

Copying directories to directories with different names

How can I copy a number of directories: directory_01 directory_02 directory_03 to different directories tmp_directory_01 tmp_directory_02 tmp_directory_03 where each tmp_directory_* directory ...
4
votes
3answers
701 views

copy all files that have no extension

We can copy some file by extensions like this: cp *.txt ../new/ but how can I copy all files that have no extension?