Questions tagged [cp]

cp - Command-line tool to copy a file

Filter by
Sorted by
Tagged with
1
vote
0answers
251 views

See the overall percentage completion of a recursive cp command

Is it a simple way to track the completion of a large cp -r command? To get something like: copying 10% ... copying 20% Maybe using a pipe to another command? cp -rvv orig dest | show_as_percent ...
3
votes
2answers
195 views

Rsync and cp command to copy “.txt” files to single directory (only if already exists)

I have a directory structure with multiple .txt files with multiple directories. I want to copy all these .txt files into one particular directory. I have given below my directory structure: Dir_1 ...
2
votes
3answers
117 views

How to copy just certain words from a file into a new file

I have a homework assignment where I have a file that is a large list of words. I have to copy into a new file all the words starting with c and name it cwords. I can see a list of the words by ...
4
votes
1answer
11k 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 ...
-1
votes
1answer
150 views

progress bar while copying a file from hdd to usb drive (no rsync)

I used to rsync and xfr#1, to-chk=0/1, what do they mean? but with the recent rsync bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=862899 I don't know the solution. Does anybody of any ...
0
votes
3answers
92 views

Sort and copy files from several directories

I have a directory containing several sub-directories, containing files. I would like to sort the files in each of these directories by name alphabetically and copy the first file from each ...
0
votes
1answer
355 views

How do I use `cp -R` to copy all files to a subfolder without copying the subfolder as well?

I have an image folder which I am trying to copy into a subfolder of itself, so I can resize the images there. It looks something like this: Sephs-MacBook-Pro:photos seph$ ls 100x100 ...
5
votes
6answers
9k views

Check command success in bash

I'm currently writing a small script to backup bulks of floppy disks and format them afterward for later use. I use dd to copy the disk's image and cp to copy all the files on the disk. Here are the ...
2
votes
0answers
56 views

Simple method for copying a file and preserving it's path? [duplicate]

I want to copy a file from drive A to drive B, preserving the file's path. For instance /A/x/y/z/file.txt to /B/x/y/z/file.txt However, you cannot cp a file to a directory that doesn't already ...
10
votes
1answer
2k views

Are there any disadvantages of `cp --sparse=always`?

Is there any reason not to use use --sparse=always with every invocation to cp? info cp says: ‘--sparse=WHEN’ A “sparse file” contains “holes”—a sequence of zero bytes that does not occupy ...
3
votes
2answers
53k views

cp all files and subdirectories in a directory ksh

How can I do a cp to copy all files including all sub-directories in the current directory. I looked at the man page, but I can't figure out how to do it. EDIT: (my *nix is Linux)
1
vote
1answer
321 views

Why 'cp --preserve=links' doesn't work? [duplicate]

Why cp --preserve=links doesn't work? I want to copy some symbolic links.From man page: --preserve[=ATTR_LIST] preserve the specified attributes (default: mode,ownership,timestamps), if ...
3
votes
2answers
15k 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: /applis/rgedff/pur/bin/../bin/lib/...
1
vote
1answer
42 views

centos 6.3 bug command[cp] [closed]

echo "aaa" >abc.1.txt echo "bbb" >abc.2.txt cp abc* linux no error bug same command [ cp abc.1.txt abc.2.txt] cp abc.* = cp abc.1.txt abc.2.txt why?
4
votes
1answer
548 views

How to force Fedora 27 to write to USB flash drive immediately?

My Fedora 27 writes actual data to USB on umount. Before umount it works only with links or something like that. So, for example, when I transfer a big file of 5 GB cp /home/iam/bigFile /run/mnt/iam/...
0
votes
1answer
149 views

Define target directory with flag in `scp` or `rsync` (like `cp -t`)

Since I'm often copying a varying number of specific files to a (rather convoluted) destination directory over the network, my life would be so much easier if I could use cp's -t flag: With it, you ...
6
votes
2answers
3k views

cp losing file's metadata

I have an Asustor NAS that runs on Linux; I don't know what distro they use. I'm able to log in it using SSH and use all Shell commands. Internal Volume uses ext2, and external USB HDs use NTFS. ...
1
vote
3answers
252 views

How to batch cp files and rename by adding prefix in current directory in one command-line without using for loop?

Example: . ├── f1.md ├── f2.md ├── f3.md ├── f4.txt ├── f5.csv ├── f6.doc ├── s1 ├── s2 ├── s3 └── s4 4 directories, 6 files I want to copy f1.md/f2.md/f3.md in current directory, and the results ...
2
votes
1answer
248 views

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

I want to copy and rename multiple files from one directory to another. Particularly, I want something like this: /tmp/tmp.XXX/aaa.original.txt /tmp/tmp.XXX/bb5.original.txt /tmp/tmp.XXX/x2x.original....
1
vote
1answer
8k views

copy a file to a destination with different names

I want to copy a text file to a directory with multiple names with curly braces: cp /path/to/file/a.txt /path/to/file/{b,c,d}.txt But it gives me the error: target '/path/to/directory/d.txt' is not ...
22
votes
1answer
21k views

cannot create regular file 'filename': File exists

I've been getting this strange error message in one of my build scripts - cp fails, returning the error "File exists". I've even tried using cp -f, which should overwrite the file if it exists, but ...
2
votes
1answer
128 views

Is it possible to “clone” with rsync a folder to another by creating only symbolic links

Is it possible to use rsync to "clone" a folder to a new folder but create the new folder tree structure as a symbolic link to the SOURCE. cp -as SOURCE DEST -s, --symbolic-link make ...
0
votes
2answers
244 views

make copy of file and place in new directory using relative path [duplicate]

i have been stuck on this question for my lab for linux class
1
vote
0answers
55 views

what is the best approach to move /var?

we have linux red hat 7 we want to keep the /var on other volume so the plan is to: mkdir /var_copy cp -rp /var/* /var_copy umount /dev/mapper/vg-a-var /var rm -rf /var mkdir /var mount /dev/...
8
votes
2answers
2k views

cp: invalid option — 'o'

I'm following an installation script on GitHub and one of the steps is: cp sources/openssl/1.0.1p/Android.mk -o sources/openssl/$OPENSSL_VERSION/Android.mk But my terminal threw an error cp: invalid ...
2
votes
1answer
72 views

Place ht access file in webroot of each directory bash script

I'm trying to write a script that will descend into each subdirectory in /home and find the public_html folder within. Then it will check if an .htaccess already exists, if it does write that to a ...
0
votes
1answer
162 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 ...
4
votes
2answers
2k 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 ...
1
vote
0answers
460 views

cp on nfs share claims to fail but actually succeeds

I am dealing with an nfs share where I have read/write permissions. Everything seems to work fine, except when I copy files to subdirectories. Then the cp command complains that file creation was ...
2
votes
1answer
2k views

Copy directory, but fail if file already exists at destination

cp -a foo/* bar/ will copy the contents of foo into bar, replacing any files that already exist. I can use the -n flag to make cp not overwrite existing files or -i to make it ask interactively ...
0
votes
1answer
315 views

Copying a folder using xargs

A command gives me the path of a folder. I want to copy the content of this folder to the current working directory. What I tried so far is bundle show minima | xargs -I{} cp -r {} ./ where ...
0
votes
1answer
78 views

How to copy matching files from directory/subdirectory to a another directory

I am having following folder structure. applications (main directory) - 1 (sub directory) application_1.pdf - 2 application_2.pdf - 3 application_3.pdf I wanted to copy all the ...
0
votes
1answer
586 views

Copy modified files from one server to other

Scenario: 2 Servers (*.12 and *.13) CakePHP "application" on both of them. *.12 is "Production" Server *.13 is "Development" Server Now I want to copy all files modified in the last 2 days from ...
1
vote
2answers
2k views

How do I copy directories and symlink files?

I have got a directory of huge files (total ~ 1TB) and I don't want copy them around. However, I'd like to work around them, so it would be convenient to have them linked in a directory hierarchy I ...
4
votes
5answers
11k views

Find and copy directories containing file type

I have a directory "Movies" containing subdirectories "Movie Name". Each subdirectory "Movie Name" contains a movie file and related image/nfo files etc. I'm trying to copy all directories containing ...
1
vote
1answer
130 views

Mass file+folder+directory move

So we have a bunch of src files that are old and out-dated and need to be moved to our new NAS storage. (I don't know why we are keeping them). Is it possible to copy all the files and folders with ...
2
votes
2answers
294 views

open a file and copy the listed files to another folder

I have a file named file1.txtcontaining file names like below : filea.txt fileb.txt filec.txt I want to copy the files listed in file1.txt to another folder. What is the UNIX command to use? (the ...
1
vote
1answer
1k views

Copying Tapes Data to Disk [closed]

Is there any command which serves as copy paste option: ABC on tape is copied as ABC on disk, without assigning a self label/name rather using the native file name. I am using DD, TAR and Tcopy (for ...
14
votes
1answer
29k 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 ...
2
votes
2answers
869 views

Copy a folder and its content to all Nginx vhosts host

I am interested to know if a single command line that would allow me to recursively copy a folder to all of our NGINX Virtual Host htdocs folders: I need to copy that folder to all hosts located in ...
2
votes
2answers
157 views

How-to overwrite directory on multiple places with 1 source directory

So today I encountered one of my PHP files was outdated so I've got to overwrite the phpthumb directory on the entire server. Multiple websites use this folder on multiple unknown locations, so how ...
0
votes
2answers
41 views

not able to copy after login to remote server

Below is my code to copy one folder from one path to another path after login to remote server. Problem I am facing, once after login to remote server I am not able to copy the source directory to ...
3
votes
3answers
1k views

Merging two directory without copying the files

Let's say I have as follows : Folder A C1 file a A2 Folder B C1 B2 file b B3 What I want is to merge these two folders, which would give me : Folder C ...
0
votes
1answer
581 views

Copy selected files had subtitutions in name

I have some folders: oldA with A_1.aaa, A_2.aaa, A_1.bbb, A.def, A.ghi oldB with B_1.aaa, B_2.aaa, B_1.bbb, B.def, B.ghi and so on and need to copy them to another folder with selection. I want ...
6
votes
2answers
9k views

Verify file integrity by comparison with original file

I'm copying 1TB of a FreeNAS Server to a USB External Drive, I'm doing it with "cp", and after the copy has finished, I want to compare the files from original files to the copy one. Is this possible?...
0
votes
1answer
68 views

specific copy of files

I have files and directories that have same suffix ( from 0 t0 310). and I want to copy file(0) to directory(0), file(10) to directory(10) and go on till file(310) to directory(310). Is there any way ...
1
vote
3answers
116 views

script for copying directories with particular increment

I have directories which are named as 0.1, 0.15,0.2, 0.25, 0.3,0.35 and so on. Now I want to copy directories at particular increments say of 0.1 together to a separate directory. Say directories 0.1,...
4
votes
2answers
4k views

copy recursively skipping directories with specific name

I have a directory with ~100 Gb. I need to copy this directory to other place skipping specific folders (there is a lot of them). The following is a wrong code to demonstrate my needs. $ cp -r ~/...
1
vote
0answers
92 views

Light file copy with diff

Is there a way to copy a file by creating another instance of it, that is not created as a hard copy, but by a link with the difference that any edit to that file will be saved in an diff file? I ...
6
votes
1answer
3k views

Override an existing folder with cp

Is it possible to override an existing folder with cp? Example: tux@linux:~ $ cd /tmp/test/ tux@linux:/tmp/test $ mkdir A tux@linux:/tmp/test $ cd A tux@linux:/tmp/test/A $ touch 1 2 3 4 tux@linux:/...