Questions tagged [cp]

cp - Command-line tool to copy a file

Filter by
Sorted by
Tagged with
0
votes
1answer
476 views

Hard disk usage 100 % without any read or write activity

I started a big file transfer and it's taken a long time. I checked the disk activity with nmon and it says the (NTFS) disk is being 100 % busy and read and write speeds are at zero. I used cp -r ...
2
votes
1answer
54 views

Why did `cp -uav` of a git repo show “removed” for some files?

I used cp -uav to update a copy of a git repo, including uncommitted files. Why did it say it's removing files? It looks like this: $ cp -uav repos copy removed 'copy/repos/h/.git/objects/e6/...
0
votes
1answer
87 views

Why “.” is required copying a file from one directory to another directory?

While reviewing someone's bash script, I ran into following command. My question is why "." is required for copying a file from one location to another? To me it seems unnecessary. cp source/foo.xml ...
6
votes
1answer
439 views

why linux cp command don't consume disk IO?

os: centos7 test file: a.txt 1.2G monitor command: iostat -xdm 1 The first scene: cp a.txt b.txt #b.txt is not exist The second scene: cp a.txt b.txt #b.txt is exist Why the first ...
2
votes
1answer
83 views

cp error message uses different quoting on Ubuntu 12.04(?) and Fedora 24

I develop on F24 and my tests pass, but when I try them in Travis CI, they fail. AFAIK, they (Travis CI) use Ubuntu 12.04 VMs. The test compares the output of a run with previously gathered "gold" ...
2
votes
1answer
358 views

Copy file and replace string

I am trying to write a script that copies the file log_REPLACE, and replaces the string REPLACE in the name of the file, and within the file with the letter A and B. So I want to create log_A, and ...
3
votes
1answer
2k views

How does copying the Debian iso directly to a USB drive work?

I downloaded a Debian DVD and following the docs mounted a USB and simply did this: cp /dev/sdb mydebiandvd.iso sync After running these commands I ran lsblk and found the sdb thumb drive said it ...
3
votes
2answers
339 views

How to check progress of cp when target is a whole-device

To create a debian install stick, one copies the iso to the device: cp debian-testing-amd64-DVD-1.iso /dev/sdb per this page: https://www.debian.org/releases/jessie/amd64/ch04s03.html.en according ...
0
votes
1answer
80 views

Understanding Copy command

I have one copy cp command related question: In my home directory, there is a folder which is known as WebDev, Inside WebDev folder, there is a target folder which contains WebDev.rar. Now, I am ...
0
votes
1answer
147 views

cp/rsync both grind to a halt when copying to USB/Micro SD

I'm trying to transfer about 20GB of music from my Arch Linux laptop to a Micro SD card, via a USB reader. The process starts off fine; the first ~50 songs take a combined one second, although from ...
1
vote
2answers
1k views

Working with /dev/null with cat or cp vs touch

In a tutorial about public key infrastructure the author sets up a database to work with when setting up a Root Certificate Authority: cp /dev/null ca/root-ca/db/root-ca.db cp /dev/null ca/root-ca/db/...
1
vote
2answers
3k views

How to copy contents of a folder without affecting the permissions of destination folder?

I want to copy all files and folders from one directory to another without changing the permissions of the destination directory. Where origin folder is 555 and destination folder is 775. If I use ...
1
vote
1answer
41 views

How to treat cp -r always as directory?

I have to copy some files and I have a field where I write the destination path. But if I do not write "/" at the end, it takes the last word and creates a file with that name. How can treat ...
1
vote
0answers
55 views

Why isn't tee outputting to stdout? [duplicate]

I'm using tmux and cueing up a very large copy: /bin/cp -aRv /mnt/src/folder/. /mnt/dest/folder/ 2>&1 | tee /log/big_copy_log When I run without tee, I see output on the terminal just fine. ...
1
vote
2answers
198 views

How to find and copy files based on extension?

I have a photorec folder from a data recovery process that has 2481 folders with the recovered files. The folder names are in the sequence recup_dir.1, recup_dir.2 ... recup_dir.2481 I got a list of ...
0
votes
2answers
1k views

Appending one file to another [closed]

Simple question. I'm trying to append one file to another. I've tried this: cp temp1 >> temp2 temp3 But, it doesn't seem to work. Thanks.
1
vote
1answer
48 views

cp the only files when permission is granted in the a directory

I would like to cp the whole directory, however inside that directory, it has some files which I don't permission to cp over. Is there any flag I can use in this case. Or are there any other command I ...
2
votes
2answers
139 views

Copy file to destination based on ini file

I have a few thousand subdirectories in a directory, each containing one config.ini file and one JPEG image. The ini file contains (including but not limited to) a section that encodes the time, when ...
3
votes
3answers
2k views

Copying newer files only

I have a simple shell script. What i'd like to do, is copy the files in /home/imp/imp/msgs/ to /home/imp/imp/msgs/bak/, but only if they are newer in the source directory than the destination ...
3
votes
3answers
12k views

How to copy “just files” recursively

Suppose I have this structure for folder0 and subfolders and files in it. folder0 subfolder01 file011 file012 subfolder02 file021 file01 file02 I ...
0
votes
2answers
1k views

source and destination path for the copy command in single file then how to copy?

I have a single file which contains source file paths and destination file paths. example $ cat test.txt /home/data/source.txt /home/code/destination.txt /home/abc/def.txt /home/mnp/xyz.txt ...
1
vote
0answers
704 views

Android: cp whole directory command [closed]

In Android shell (also a linux distro), I want to copy a whole folder to a different folder without specifying the folder name. For example: cp -R /storage/emulated/0/.Data /storage/emulated/0/backup ...
6
votes
2answers
14k views

cp after xargs not working

I run debian jessie on Host 64-bit and in virtualbox 32-bit. To spare traffic I try to cp the i386 packages from host to the shared folder, for using them in virualbox. My Hostname/var/cache/apt/...
1
vote
1answer
58 views

Rsync , cp or any utility add specific filtered data back from original file to analyzed file [closed]

I have mistakenly deleted some useful data from my backup file but the problem is I have so far analyzed huge amount of backup file and now i cannot take a another backup and start analyzing from ...
1
vote
3answers
2k views

How to override all folders with cp?

I have two folders, and I would like to do: cp -R folder1/ folder2/ So that I all the sub folders missing in folder2 will be created, and there files copied. And all the folders in folder2 that are ...
0
votes
1answer
141 views

rsync and cp producing different results

I was upgrading ModX today and tried to merge the new installation with the existing copy on my server. On their site ModX says to "merge directories", which I assume means to recursively copy every ...
6
votes
1answer
922 views

Copy nested directory structure ignoring all directories of a certain name

Say I have a big nested directory projects/ and I want to recursively copy the entire directory excluding any sub-directory with the name node_modules/ or env/. I don't know how many node_modules/ or ...
1
vote
2answers
7k views

cp says “same file” for two different directories

I have directory A with subdirectory B and am trying to copy everything from B to A. Within A, I run cp -ar B/ ~/A, and get the message that "cp: âB/â and â/u/username/A/Bâ are the same file" ...
0
votes
1answer
703 views

Why does “find / -name '*.txt' | cp /junk” not work?

If I want to find any files with .txt in the name, and for every match that is found copy it into the /junk folder the following could be considered to work; find / -name "*.txt" | cp /junk but ...
2
votes
1answer
666 views

Unexpected behavior of cp -a on symbolic links

When copying symbolic links from incremental backups, unexpected behavior can occur. For example: # mkdir 0 1 2 # touch 0/a # ln 0/a 0/b # touch 1/a # ln 1/b 1/a So directory 0 looks like a b->a ...
1
vote
0answers
48 views

Copying directory from one folder to another didn't work [closed]

I followed exactly it is mentioned over here in this tutorial: cp -avr /home/vivek/letters /usb/backup whereas , in my case, I was copying directory from terms folder to terms_code. I ran the above ...
4
votes
1answer
10k views

What is the difference between `dd`, `cp` and `rsync`? [closed]

Besides the explanations from the man pages and --help information, in which way do the commands dd, cp and rsync differ when used to copy files? In which context is each of these superior to the ...
4
votes
3answers
1k views

create empty files with same directory structure as reference directory

I have a Dir1 with multiple subdir and files inside it. I intend to copy the Dir1 to Dir2 so that all the files in it will be just empty files but with same file name as Dir1. Then I intend to push ...
2
votes
3answers
958 views

move files in a loop

I have files named file_1_supply.csv file_2_supply.csv file_3_supply.csv ....... file_30_supply.csv I want to copy these files from one folder to another in Linux. The problem is there are also many ...
0
votes
2answers
279 views

Copying files in bash

I want to copy all files (included sub-folders) from $HOME directory to Desktop in bash. And as you know the Desktop is in $HOME. So, when I copy all files I get the message like this: cannot copy ...
3
votes
1answer
316 views

Alternative to cp command since cp throws warnings and returns with error code while used with NFS

I was using the following copy command to take backup of my datastore cp -pr $src $dest Which gives me the following warning while using with NFS and returns an error code but the files are actually ...
1
vote
0answers
905 views

How to copy directory and ignore errors

I have a root Linux shell open on my Android device, and while using cp to copy a directory, I get an error. I think I know where the error is coming from, so that is not my question. I want to find ...
1
vote
0answers
532 views

Why cp/mv can't be interrupted until the end of the current file

Let's say I want to copy 3 large files (4Gb each) with this command : cp -v file1 file2 file3 dest_directory/ When cp is copying the second file, and I press CTRL+C, the copy is not canceled until ...
3
votes
2answers
277 views

Take all the file structure but these directories

I want to copy an entire file structure (with thousands of files and hundreds of directories), it's a hierarchy of directories and there are those node_modules directory that I want to exclude from ...
0
votes
2answers
11k views

How to copy files of particular date from one path to another path in Unix [closed]

I want to copy a files of particular date from one directory to another directory. Can anyone suggest me the Unix command for that ?
1
vote
0answers
57 views

Can cp -r replace the cp -a in this case?

If I understand correctly the option cp -a someDir is essentially to archive a dir i.e. to copy its contents/structure and preserve access time & access rights. And it differs with cp -r someDir ...
0
votes
1answer
75 views

What is wrong with my copy command?

I did the following to my mac with the intention to copy the /etc in /tmp to try something: $cd /tmp $cp -a /etc . $cd etc -bash: cd: etc: No such file or directory $ls -all etc ...
0
votes
2answers
687 views

What is the equivalent to “cp --backup=numbered” in alpine linux?

I'm porting a script from ubuntu to alpine linux 3.4 (docker image). I can't seem to find a way to do "cp --backup=numbered" in alpine. Is there any way to install a more complete "cp"? Thanks
1
vote
4answers
815 views

Does the cp command change file structure?

I am fairly new to Linux and the Debian distro so please don't beat me up too bad. My thoughts are that when you use the cp command to copy files from drive to drive, it does not change the file ...
0
votes
2answers
167 views

cp'd a file over another file with same name

I just issued: cp -r Photos ../ to another directory that had folder with the same name. I'm still in the terminal, but wanted to know if I could undo this somehow?
0
votes
2answers
517 views

How to copy files and directories without copying directory contents?

I have a find command that selects some directories and files to be copied to a different location (with --parents). What I'd like is for the directories that are output by the find command to be ...
-1
votes
2answers
53 views

Copying files while maintaining file attributes

Say, if I want to copy /etc/bin to a folder while maintaining the file attributes as well as parent directories. [The target folder should not just contain bin folder but /etc/bin.] Is the possible ...
1
vote
1answer
239 views

How can I copy a file into the subfolders of multiple directories with the same prefix?

I have a file called "foo.txt" in my current directory. This directory also has folders named myfolder1, myfolder2, etc... Each of these folders has a subfolder called "constant". I want to copy "...
1
vote
1answer
411 views

$_ not working with copy and move commands

I face the problem with $_ usage, which $_ special parameter in terminal, And its call the last argument of the previous command. It was not work with cp and mv command in gnome-terminal.It happen ...
1
vote
1answer
155 views

Is it possible to pipe mount into cp?

This code is wrong but is there something to do its job? mount somefile.iso | cp - Directory More specifically, I have read-only issues while using the original mounted files so I need a copy.