cp - Command-line tool to copy a file
1
vote
3answers
76 views
`cp` permission denied when copy a file owned by `root`
I have a folder udp_folder2
d------r-T 41 root root 4096 Apr 26 21:17 udp_folder2
when I'm with user other than root, I can't cp -r it into a new folder
it says: Permission denied
...
2
votes
1answer
29 views
exec cp failes from script, yet works when issued directly
I have a script that copies SQL backups to a windows server. Here's the line from /etc/fstab:
//my.win.box/share$ /winshare cifs ...
0
votes
4answers
55 views
concatenating multiple files with multiple headers
Im trying to concatenate multiple files with multiple headers to have one file with all the information in it for example.
File 1:
Numbers
1
2
3
Letters
A
B
C
File 2:
Numbers
4
5
6
Letters
D
E
...
1
vote
1answer
34 views
Unzip file contents, but without creating archive folder
I apologize if this question has been asked but I can't seem to find an answer. I'm VERY noob to *nix systems so perhaps I've "seen" the answer but didn't know what I was looking at.
I have a file ...
0
votes
3answers
79 views
Why does this work: “cp image.bin /dev/mapper/loop0p1”?
Why does this work?
cp image.bin /dev/mapper/loop0p1
image.bin is a partition image.
I have tried it and works, but why? Shouldn't a dd be used?
2
votes
2answers
97 views
`cp -al` snapshot whose hard links get directed to a new file when edited
I am trying to take snapshots of a massive folder regularly.
I have read here: http://www.mikerubel.org/computers/rsync_snapshots/#Incremental
that cp -al takes a snapshot of a folder by simply ...
2
votes
1answer
92 views
Copying a working Linux instead of installing a new one [duplicate]
It is possible to move an installed Linux from one drive to another or from one disk to another by two methods:
dd command which copies sector by sector including boot sector
cp command, and then ...
1
vote
1answer
33 views
How rename directories tree entry by entry
I have text file contain two columns:
current directory name the new name of the last entry
d_7154/d_7161/ 'Main Integration'
...
1
vote
2answers
91 views
Can one copy a relpath in one command?
I find myself doing this often enough that I wonder if there's a standard Unix way to do it:
% mkdir -p /TARGETDIR/relative/path/to
% cp ./relative/path/to/somefile /TARGETDIR/relative/path/to
In ...
2
votes
1answer
126 views
Minimal command to make a copy of a file [duplicate]
I often find myself copy-pasting long path in order to create a copy of a file
cp /path/to/file/file1 /path/to/file/file1.bkp
Is there an alternative utility that will NOT require me to type the ...
5
votes
5answers
331 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 ...
1
vote
2answers
293 views
faster alternative to cp -a
For a simple transfer of /home to another disk i use cp -a that seems to me an extremely slow way. Should like know a more efficient way to complete the task. I have /home mounted as logical volume, ...
7
votes
2answers
253 views
Why do `cp` and `rm` treat directories separately?
Why do tools like cp and rm treat directories separately from regular files? They both require the user to explicitly specify she wants a recursive behavior, or else they won't deal with directories ...
1
vote
1answer
57 views
What happens when I copy a file from one network location to another
Suppose I have three networked computers: A, B and C.
A mounts a directory from B and from C.
A/mnt/im-on-B/
A/mnt/im-on-C/
A then copies a file:
cp /mnt/im-on-B/file ../im-on-C/
What happens ...
2
votes
3answers
77 views
How to copy a list of files and adjust destination filenames on the fly?
When I don't need to adjust destination filenames I can do something like this:
$ find -type f -name '*.pat' -print0 | xargs -O cp -t /path/to/dest
It is safe because the filenames may even ...
13
votes
3answers
375 views
Is it possible to see cp speed and % copied?
I'm having problems when copy large files using nautilus (it gets stuck) so I need to copy using cp. I would like to know if there is any parameter that shows the % copied and also the transfer ...
1
vote
1answer
108 views
Killed `rm` and `cp` on nfs share
I am just testing an rsnapshot installation on my laptop which should backup to a NAS mounted via nfs on my laptop.
On one test rsnapshot died with a cp -al problem (i.e. a problem with hard links) ...
1
vote
2answers
63 views
Shell : Сopy one directory to multiple directories
There is a directory YYY and a structure on the site:
site1.ru/wp-content/plugins/
site2.ru/wp-content/plugins/
...
site10.ru/wp-content/plugins/
Task: YYY directory to copy all directories plugins ...
2
votes
3answers
72 views
How to cp or rm files based on ownership / permission
After a problem with spam, I stopped postfix
postfix stop
and checked through the mailq manually to find hundreds of thousands of unsent spam.
The spam was sent from one of the sites hosted ...
6
votes
1answer
41 views
Is there a way to express: `--link` or fall back to ordinary copy in cp (from GNU coreutils)?
Is there a way to tell cp to --link (i.e. create hard links), but fall back in the case where I am attempting inter-device hardlinks? Inter-device links aren't possible and would cause cp to fail.
...
2
votes
3answers
140 views
Use find + sed + cp to find files and copy them to a directory with a different name
I'm trying to copy a bunch of files named folder.jpg into a folder. The problem is because all the files are named the same thing, I need to rename them in the process. I know I can probably do it ...
2
votes
1answer
73 views
How can I copy a git repo from a Makefile?
I'm writing a Makefile to sync my local dotfiles with GitHub. I recently decided to also add my .vim folder to the repo. But when trying to copy the .vim folder I keep getting a Permission denied ...
0
votes
0answers
41 views
Move files replacing? [duplicate]
Possible Duplicate:
‘mv’ equivalent of drag and drop with replace?
I'd like to take a folder /a/b/c, and copy all files in /a/b/x into /a/b/c, replacing all files in /a/b/c with the ones in ...
1
vote
1answer
173 views
How to copy symbolic links while preserving the validity of the link?
Say under directory /usr/local/boost_1_52_0/stage/lib, I have a symbolic link: libboost_timer.so, which points to the regular file libboost_timer.so.1.52.0 in the same directory.
How can I cp the ...
4
votes
2answers
567 views
tar files from another directory without copying them
This should be very simple for experts in here.
I have a Linux account with user disk quota of only 6GB. There is some data-folder in /opt with about 3GB of data with when compressed comes up 1GB. ...
9
votes
6answers
309 views
How to copy every 4th file in a folder
I have a lot of files in a folder, named like 00802_Bla_Aquarium_XXXXX.jpg. Now I need to copy every 4th file to a subfolder, saying in selected/.
00802_Bla_Aquarium_00020.jpg <= this one
...
1
vote
2answers
142 views
Copying only differences?
I want to recursively copy one directory over another, however I only want to copy differences. The reason is that I'm doing this on Solaris on a volume which is snapshot, i.e. if I'm copying 100gig ...
4
votes
3answers
154 views
Copy files with deleting suffix in name
How can be done coping files that have some suffix at the end, into same dir with the smallest command possible:
Example have directory containing files:
cassandra.yml.example
database.yml.example
...
0
votes
1answer
147 views
Unix cp wildcard with directory structure [duplicate]
Possible Duplicate:
How can I copy a subset of files from a directory while preserving the folder structure?
I have a bunch of directories like this:
/Artists/Example Name ...
1
vote
2answers
231 views
How to avoid cp -r ~/some/folder/ . copying all files to the current folder's top level?
(Update: this happens on Mac OS X -- I am using Mountain Lion.) It sometimes happen that I use the tab key to complete the path, so my command may be:
cp -r ~/some/folder/ .
but it turns out that ...
3
votes
2answers
870 views
How do I copy a symbolic link?
I have a symbolic link to a file in one directory. I would like to have that same link in another directory. How do I copy a symbolic link?
I tried to cp the symbolic link but this copies the file ...
4
votes
2answers
449 views
pv for directory copy
I need to copy a very large directory (talking in terabytes here) and want to monitor the progress.
I found that pv is a nice utility, but how can I use it for copying directories recursively? (pv ...
3
votes
4answers
383 views
Make cp return an error value if the target exists
Is there a way to make cp (from GNU coreutils on Linux) return a nonzero value in case the target file does already exist?
Or is there any other small utility which is commonly available and which ...
3
votes
3answers
291 views
Copy multiple files to one dir with parallel
I'm using the following script to copy multiple files into one folder:
{ echo $BASE1; echo $BASE2; echo $BASE3; } | parallel cp -a {} $DEST
Is there any way to use only one echo $BASE with brace ...
8
votes
3answers
379 views
Flattening a nested directory
This is probably very simple, but I can't figure it out. I have a directory structure like this (dir2 is inside dir1):
/dir1
/dir2
|
--- file1
|
--- file2
What is ...
1
vote
3answers
237 views
Copy files with permission 200
I want to recursively copy a directory, preserving file attributes, which contains a directory tree including some files that have permission 200 (i.e. --w-------).
The copy command cp -ar ...
9
votes
3answers
703 views
How does “cp” handle open files?
I'm having two separate directories. The user loads a file into the first. Theres a cronjob running in the background which copies the files every 5 minutes over to the second directory.
What happens ...
4
votes
1answer
201 views
Symbolic links with ls, mv: forcing the functions to utilize “logical” addresses (remembering the original path)
It seems that for many basic functions operating on symbolic links, the physical path is used by default. However, cd works fine. When moving into a symbolic link, cd remembers where I came from so it ...
9
votes
4answers
1k views
Copying a single file to multiple directories using cp
This question is a sequel of sorts to my earlier question, Creating numerous directories using mkdir.
I am using the bash shell. I have created fifty directories, each starting with the prefix "s", ...
2
votes
2answers
261 views
How to copy a piped list of files contained spaces and apostrophes?
I have a list of files generated using find that I want to feed (pipe) to cp. My problem is that the files have spaces and apostrophes in them, leading cp to repeatedly complain that it "cannot stat". ...
1
vote
1answer
72 views
Will files created under source directory after running `cp` be copied?
Suppose I use cp to copy a directory to another place. If the process takes long, and I create a new file under the source directory, will it be copied, or it depends? Thanks!
2
votes
2answers
130 views
cp file device:directory on Minix
In my operating systems class we had to modify the boot screen of the Minix OS. I understood just about everything we did, but at the end of the make for compiling the new OS, there's a line:
cp ...
15
votes
3answers
2k views
Why unix mv program doesn't need -R (recursive) option for directories but cp does need it?
This is a kind of "wtf?" question, so I'm sorry if I will disturb someone's vision of how things should be or if I will just annoy you with the "stupid" question.
I always get messed up when need to ...
1
vote
2answers
798 views
Create symbolic links with wildcards
I have multiple hard drives with the same directory hierarchy, for example:
/media/sda/dir1
/media/sda/dir2
...
/media/sdb/dir1
/media/sdb/dir2
Two hard drives with similar names and similar ...
1
vote
1answer
109 views
Move some files on every dir to a different dir [duplicate]
Possible Duplicate:
How can I move files by type recursively from a directory and its sub-directories to another directory?
I'm quite new to Linux and specially to the shell and all of its ...
4
votes
2answers
749 views
Difference between cp -r and cp -a
Looking for the difference between cp -r and cp -a? What does recursive mean in terms of copying files from a folder?
5
votes
3answers
1k views
cp or rsync, is cp really worth it?
I hope this does not count as a question without a real answer, as I can't seem to find a good reason to use cp(1) over rsync(1) in virtually all circumstances. Should one typically favour rsync over ...
2
votes
4answers
509 views
Make directory copies using find
I have a directory with a bunch of subdirectories in it. Thus
/usr/local/src/ccl/ccl-1.8/x86-headers$ ls
elf gl gmp gnome2 gtk2 jni libc
Each of these directories has a further subdirectory C ...
4
votes
4answers
1k views
How to copy directories with preserving hardlinks?
How to move directories that have files in common from one to another partition ?
Let's assume we have partition mounted on /mnt/X with directories sharing files with hardlinks.
How to move such ...
3
votes
2answers
3k 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 ...