cp - Command-line tool to copy a file

learn more… | top users | synonyms

-2
votes
2answers
27 views

move file from desktop [closed]

I have downloaded Drupal into downloads folder in 7.1 redhat linux GUI. the thing is that I need to move it to /var/www directory using the following command and error: [root@zaid /]# mv ...
1
vote
3answers
41 views

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

Recently, I have launched the cp command to create a backup of a big directory. So, I used a command like that : cp -rv big_directory new_location Because files are big, it took long time to ...
-1
votes
1answer
90 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
59 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
26 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", ...
2
votes
1answer
41 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
9 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
2answers
302 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
2answers
541 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
29 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
141 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
66 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
45 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
35 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 ...
2
votes
3answers
288 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?
0
votes
2answers
32 views

How to find file that has read permissions from root directory?

I am trying to find files with read permissions from root directory and save them under /home/student/abc direcory: find / -type f -perm a+r -exec cp /home/student/abc {} + but it shows me the ...
2
votes
3answers
204 views

How to I copy the directory and subfolders but ignore certain files in the subfolder?

I believe the question is best asked with an example. /home test1.txt test2.txt /home/my-folder test3.txt test4.txt test1.txt, test2.txt and my-folder folder are inside /home. ...
-1
votes
1answer
16 views

Copy Month wise folders

Main_Dir | --------------------------------------------------------------------- Subdir1 ...
2
votes
1answer
83 views

Is `--reflink=auto` safe to set as default for cp?

I am currently a user of BTRFS and would like to take advantage of the CoW such that when files are copied on the same btrfs filesystem, they are automatically deduplicated by reusing the existing ...
0
votes
1answer
52 views

Copying files containing specific text preserving directory structure

Using the code in this answer, I can easily copy a file containing specific text from one folder to another. With the -r option I can also search inside directories recursively. The result is that ...
2
votes
2answers
94 views

Copy certain files from specified subdirectories into a separate subdirectory

I want to copy all .fastq files from every subdirectory that ends in '_CSF' into another already created subdirectory, dir1_CSF. I understand how to copy certain files but not from certain ...
0
votes
1answer
59 views

Are cp -r and cp -R the same? [duplicate]

A tutorial shows cp -r http://cli.learncodethehardway.org/book/ex10.html but http://ss64.com/osx/ only shows -R.
0
votes
0answers
19 views

What is the bash path difference if asterisk is inside doublequotes or outside doublequotes? [duplicate]

Task is to copy all the files (*). I have this command failed (no path found): cp -r "somedir with space/*" /tmp But this works fine: cp -r "somedir with space/"* /tmp So, what's wrong with path ...
8
votes
1answer
331 views

cp says it's removing files, but shouldn't be

Making a quick backup: root@guilmon:/mnt/backup/guilmon/home# cp -uvfrx --preserve=all /home/rena/ . The output is surprising - some files are said to be removed! removed ...
2
votes
2answers
63 views

Copy files with parent folder to a new directory

I want to copy some files and include their parent directory in the process. The current structure is similar to: /Module1/A/downloads/m13312/file.pdf /Module1/A/downloads/m17312/file.pdf ...
0
votes
1answer
61 views

cp options --no-clobber vs. --update

I want to copy a single file if (and only if) the destination does not exist. The source file changes rarely, maybe once a month. The destination almost never exists. Are there any differences ...
1
vote
3answers
86 views

How do I create a copy of a file in multiple directories?

I have a folder structure conf/ widget1/ env1.cfg env2.cfg widget2/ env1.cfg env2.cfg widget3/ env1.cfg env2.cfg widget4/ ...
0
votes
3answers
472 views

How do I copy the latest file from one directory to another?

I have 3 zip files in a directory. I want to copy the most recent version to a backup directory. My code works fine for .sh and other files, but not for .zip. Is there something else I have to do? ...
1
vote
1answer
129 views

cp: cannot stat error - when filename has Asian characters

I am simply trying to copy files using cp -r /home/user/source/ /home/user/destination/ but it throws me the cp: cannot stat /source/filename.xxx error for some of the files. When I searched for this ...
-1
votes
1answer
112 views

Copy files from find command [closed]

I am trying to copy all *file.log files found using find. The problem is all files are named the same and it is only copying over one file. I need to find a way to rename the files in the command or ...
1
vote
4answers
351 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 ...
4
votes
1answer
164 views

scp command fails executing cp

I am trying to use scp command to copy the r0.res file from local machine to a remote machine. I entered the following command: scp -v /etc/drbd.d/r0.res root@192.168.1.104 and I obtain this error: ...
2
votes
2answers
65 views

copy files from the parent location when I am inside a symbolically linked folder

Suppose I have created two folders in /tmp called parent and child. child contains a file called test-child.txt and parent contains a file called test-parent.txt. Now lets go inside the parent and ...
0
votes
1answer
57 views

? appended to filename while copying from a ssh

I am using the command cp error.log error$HOSTNAME.log the command works properly while running it separately in a server, but if it is run as script which uses ssh I am getting a ? appended to the ...
2
votes
1answer
348 views

How to view progress with sshpass and scp in linux?

In my linux terminal, I am using this command sshpass -p "pass" scp -r me8@host.ca:/cmshome/me/file /home/me/Desktop to download a file with a password in it. Without the sshpass, I can see the ...
1
vote
1answer
6k 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 ...
2
votes
2answers
194 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 ...
-3
votes
1answer
56 views

How to copy a sub directory of one directory to another?

How can I copy a directory structure named function under Dept2 directory into Dept3 directory in one shot?
1
vote
1answer
112 views

cp with interactive don't prompt before overwrite

I observed a strange behavior cp. Exactly the point is that cp did not ask me for confirmation, even with the option interactive. A test case looks like this Existing files find * -type f ...
1
vote
3answers
68 views

Replace bunch of files maintaining path

I have directory A and B. Each of them contains another directory with item.json inside. Only item.json file is persistent in directories so I cant copy-paste the directories. A: ./path/Item ...
3
votes
2answers
374 views

Copy files in same folder and replace year in its name

How can I copy a lot of files in the same directory replacing the year in its name? I have this (can be different filename and extensions): filename1-2014.ext filename2-2014.ext filename3-2014.ext ...
1
vote
4answers
323 views

Create copies of files in same directory

Lets say I have a directory with the following files: 1.txt 2.txt 3.txt I want to copy these and basically paste in the same directory making new files eg: 1.txt 1(1).txt 2.txt 2(1).txt 3.txt ...
1
vote
1answer
63 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
3answers
970 views

How to copy files from the folder without the folder itself

I'm trying to copy files and subfolders from A folder without the A itself. For instance, A folder contains next: | file1.txt | file2.txt | subfolder1 Executing next command gives me ...
0
votes
0answers
44 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 ...
3
votes
1answer
239 views

Mac OS X combine cp and cat to sequentially copy and rename files in list

I am using a MacBook Pro OS X 2013 model. I have a list of filenames in a text file named list.txt separated by line breaks list.txt exactly like this, but this list is going to be long e.jpeg ...
1
vote
1answer
207 views

how is cp -f different from cp --remove-destination?

in the cp manpage, it lists the -f/--force option as: if an existing destination file cannot be opened, remove it and try again for the --remove-destination option it says: remove each existing ...
1
vote
1answer
188 views

what is the purpose of cp -s?

as the answer to this question shows, Is there a difference between hardlinking with cp -l or ln? The purpose for creating the -l option for the cp command is to recursively hard-link (the contents ...
1
vote
2answers
378 views

do not show error if file doesn't exist on copy, without sending to dev null

I want to avoid my script posting an error if I try to cp a file that does not exist. However, I would like error messages to print out for any other error, such as insufficient permissions. This ...
1
vote
2answers
76 views

May cp override subdirectories with the same name?

I downloaded an Adobe flash plugin, It includes a .so file and a directory called usr. In this folder, it has sub-folders like bin, lib, lib64, share. In the readme file, it says I need to do the ...