cp - Command-line tool to copy a file

learn more… | top users | synonyms

5
votes
3answers
678 views

Batch copy to multiple directories

I have about 9000 files in a directory and I want to mv them into 90 files in 100 directories by filename order, ignoring any remainder. In Copy multiple files from filename X to filename Y?, Caleb ...
4
votes
4answers
5k views

copying multiple files to multiple directories

I've a problem copying many files in different directories. Let me explain better: Let's say I have the following in a dir: $ ls file1 file2 file3 file4 file5 dir1 dir2 dir3 and I want to copy ...
1
vote
1answer
274 views

Switching source and destination (or undoing the mv, cp operation)

mv or cp commands both expect source and destination as arguments. In case you want to undo the change you made, or just change the source and destination you supplied before, what is the quickest ...
4
votes
2answers
4k views

issue with find -exec cp

Consider this example (newbie alert): touch test0 touch timestamp touch test1 sudo find /var/www/import -iname 'test*' -newer timestamp -exec cp {} new \; It actually copies file test1, but it ...
1
vote
2answers
137 views

How to copy a file and move it to a location using unix

I need a file to stay in the same location but also move it to a different location. What am I doing wrong? cp RubyTest.sublime-settings \ ~/Library/Application Support/Sublime\ Text\ ...
1
vote
1answer
249 views

What happens if a cron script tries to copy a directory at the same time as another process is writing to it?

For example, if I have a java process that (once every 2 hours) takes a backup of a large file, like 500mb, and places it into folder A on HDD A, and I want to schedule a cron script to copy the ...
2
votes
2answers
133 views

debian dead when copy over 1GB

I have a Debian Squeeze system with an AMD64 processor. When I try copy over 1 GB, the computer dies (no reboot, completely down), and the logs don't contain anything useful. The temperature of the ...
2
votes
2answers
5k views

Batch copying/moving files in unix?

Is there a way to batch copy/move files in unix? I thought it might be an option for cp/mv but I can't find any way to do it.
2
votes
2answers
181 views

Using cp, what is the difference between copying to DEST and DIRECTORY?

In the man page for cp, what is the difference between copying to DEST and DIRECTORY? cp copies a SOURCE to a DEST and SOURCES to a DIRECTORY. SYNOPSIS cp [OPTION]... [-T] SOURCE DEST cp ...
2
votes
3answers
247 views

Invoking cp from within BASH and using the -u option

Is there a way to have cp's --update option print files that did not copy because the source directory contained a newer version of the file?
6
votes
2answers
2k views

How to replace a symbolic link with a copy of a file it links to?

Having a (single, no batch filesystem processing needed) symlink, what a command line to use to replace it with a copy of the file it links to?
1
vote
1answer
390 views

Can I get the backup option of cp and mv to work with directories?

--backup[=CONTROL] make a backup of each existing destination file The man page does say that it works on file. It doesn't seem to have any effect on directories. Is there anyway to make this ...
0
votes
3answers
2k views

How do I cp the folder, not just the folder content?

Let's say I have folder structure like this: /parentFolder/ folder1/ folder1.1/ file1 folder2/ file2 How do I copy folder2 inside folder1.1 so that file2 is also in ...
7
votes
1answer
192 views

Strange behaviour in recursive copy

Could someone explain why this happens? Most specifically: Why is one 1's content copied to f? And why is f copied to g? $ tree . 0 directories, 0 files $ mkdir 1 $ mkdir 2 $ touch 1/a $ touch ...
5
votes
3answers
12k views

Copy first n files in a different directory [duplicate]

Possible Duplicate: How to move 100 files from a folder containing thousands? Is it possible to copy only the first 1000 files from a directory to another? Thanks in advance
2
votes
2answers
3k views

How can I selectively copy files from one directory to another directory?

On Linux, how do I selectively copy most – but not all – files from a directory (dir1) to another directory (dir2)? I do not want to copy *.c and *.txt files to dir2. The cp man page ...
1
vote
0answers
521 views

Can't make a copy of /var/lib/mysql/ibdata1

I have a RedHat Linux server and I'm trying to make a copy of /var/lib/mysql/ibdata1, but I'm receiving an error saying permission denied and the file cannot be opened. I'm logged in as root user and ...
4
votes
1answer
509 views

Only use mtime comparison with rsync?

Is it possible to sync files via rsync and let rsync only compare mtime informations? Or is there another tool for this job? That means that such a tool only copies src to destination if the src is ...
2
votes
3answers
1k views

cp launched from code results in cannot stat '/tmp/somedir' works in shell

I'm working on making some scripts more elegant by implementing them in a real x application etc... At some point in the scripts we basically want to take everything from a mounted removable storage ...
4
votes
2answers
4k views

Using regular expressions with cp

This is a simple question. I'm trying to copy all of the files in the current directory that start with "axis-2" and end with ".jar" into a target directory, let's say it's ~/MyDirectory. My first ...
3
votes
1answer
297 views

Copy files in different subdirectories that excludes a string

I'm trying to copy all files of a type in a given directory and subdirectories but excluding files of a different type. find /var/ftp/pub/bs -iname "*foo*.foo" -exec cp {} /var/ftp/pub/bs1 \; ...
4
votes
1answer
1k views

copying device nodes

I'm trying to transfer a working Linux installation to a new larger disk, so I've attached the new disk on a USB port, partitioned it and created filesystems. While copying all the files over I hit a ...
4
votes
2answers
2k views

Permission denied (even as root) on a mounted ISO image with Furius ISO Mount

I mounted a ISO image with Furius ISO Mount. I cd to the mounted directory and tried to copy a file with sudo cp file /dir but cp writes error message cp: cannot stat `file': Permission denied ...
5
votes
3answers
2k views

recursively copy only images and preserve path

I'm working on a website migration. I have a scrape of the site, with all the files and directory structure as you would see them in the URL. I want to pull all images, maintaining the directory ...
3
votes
3answers
346 views

Delete files in a directory which are also in another directory

I copied a directory using this: cp -r dir/ ../../ without thinking and realized that it copied the contents of dir instead of actually dir to the above directory. Now I have a mess of files I need ...
28
votes
4answers
14k views

Difference Between cp -r and cp -R (copy command)

cp- r is meant to copy files recursively, and cp -R for copying directories recursively. But I've checked, and both appear to copy both files and directories, the same thing. So, what's the difference ...
4
votes
3answers
3k views

How do I move some but not all files from one directory to another?

I need to move my files from one directory to other. But there is some issues. My file name pattern is like: apple.0, apple.<n>, n -> {0,1,2,3 ...~ } so mv apple.* will not work, because ...
5
votes
1answer
397 views

ACL mask does not work as expected

If I copy a file with a base ACL of: u::rw-,g::r--,o::r-- into a directory with a default ACL of: u::rwx,g::r-x,g:users:rwx,m::rwx,o::r-x I obtain a file with mask of m::r--. I would have ...
28
votes
2answers
8k views

Why doesn't cp have a progress bar like wget?

Please note that I don't ask how. I already know options like pv and rsync -P. I want to ask why doesn't cp implement a progress bar, at least as a flag ?
2
votes
2answers
312 views

How to update a content management installation by overwriting existing files via ssh and shell?

I have installed a cms (modx) on a webserver running CentOS 5 and Apache 2.2. Now there is a new version and I would like to update it. The instructions in the modx-wiki suggest to overwrite the ...
1
vote
2answers
1k views

Is there a BASH command for copying all files from a directory tree and putting all the files in a single directory?

I have a ton of notes categorized into folders, but I think it might be better to put them all into one folder instead. Is there an easy way to do that?
4
votes
1answer
2k views

Batch copy and rename with regexp

I am wondering whether there is a way how to copy and rename a bunch of files without scripting. I have files with names like prefix_12345678901_12345678901_suffix.ext and I need to copy all of them ...
6
votes
5answers
4k views

How to copy all html files from a directory tree to a single directory?

I want to copy all the .html files in myDir and its subdirectories to ~/otherDir. Here's what I tried (it doesn't work): $ find myDir -name *.html -print | xargs -0 cp ~/otherDir usage: cp [-R [-H | ...
7
votes
4answers
15k views

Copy multiple files from filename X to filename Y?

I'm pretty noob when it comes to unix commands. What I want to do is to copy files within a lexicographic range. Example of files: -rw-r--r-- 1 root root 15276 Oct 5 2004 a2ps.cfg -rw-r--r-- ...
2
votes
2answers
2k views

Copy multiple files and append to end of filename

Seems like I really shouldn't need to create a script for this. I'd like to do something cp /etc/*.conf $1.orig or cp /etc/{a.conf,b.conf} _firstarg_.orig Is there a quick and painless way of doing ...
5
votes
2answers
1k views

Copy from linux to windows every minute

I currently quickly setup a way to copy files from my linux machine to a windows share that multiple people can access, but I'm looking for a better way. In Windows 7, I made a folder accessible to ...
0
votes
2answers
624 views

SSH Copy Limit?

So I have a small little Ubuntu server set up, with some rather large files that I've allowed a few people to copy from their putty window. Anyways 2 questions: Lets say a person on windows wants to ...
15
votes
2answers
2k views

What happens if a file is modified while you're copying it?

What is the effect of copying a file say fileA.big (900mb) from location B to locationC. If during that cp operation, say 35% through the process, fileA.big is appended with new information and grows ...
4
votes
4answers
1k views

Copy text from one terminal into another

I am logged into ssh to a university account from my home computer. Then I find a file that I want to copy onto my local system. So I open a new shell terminal and am about to use scp to copy that ...
29
votes
3answers
35k views
0
votes
1answer
1k views

Why can I not copy a direcotry from *nix to a mounted smbfs share on Windows 7?

I've mounted a Windows 7 directory on my FreeBSD box via smbfs: mount ... //ROOT@BARYONYX/GVKV on /usr/home/gvkv/win (smbfs) but for some reason when I try to copy a directory: cp .vim /win I ...
10
votes
3answers
7k views

copy recursively except hidden directory

How do I copy recursively like cp -rf *, but excluding hidden directories (directories starting with .) and their contents?