Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [cp]

cp - Command-line tool to copy a file

0
votes
2answers
19 views

Recursively copying a folder to an empty subfolder

How to copy all the content of the folder /foo/bar, which contains the file /foo/bar/a to an empty subfolder /foo/bar/subfolder without ending up with the file /foo/bar/subfolder/subfolder/a. Doing cp ...
4
votes
1answer
254 views

systemd and copy (/bin/cp): no such file or directory

While manually copying the file the following works, as below: userx@x:~$ cp -rv /opt/test-bak/* /opt/test/ '/opt/test-bak/file1' -> '/opt/test/file1' '/opt/test-bak/file2' -> '/opt/test/file2' ...
1
vote
1answer
22 views

cp multiple files do not work in bash script

I would like to run the below command in a bash script but, it doesn't work. command: cp /tmp/first/{abc.conf,xyz.conf} /tmp/backup/ bash script: firstDir=/tmp/first #secondDir=/tmp/second ...
2
votes
1answer
38 views

“cp: target '…’ is not a directory” during while loop

I have a directory of files whose names I want to shorten: (3) andrew@andrew Learning_Plans $ ls -al total 580 drwxr-xr-x 2 andrew andrew 4096 Apr 10 21:40 . drwxr-xr-x 7 andrew andrew 4096 Apr 10 ...
1
vote
2answers
75 views

How do I get commands in a bash script to complete? (files get truncated with cp)

I have a server that receives backupname.tar.gz files in /home/my_user/drop directory every hour. I installed incron utility and use incrontab -e entry to run a script whenever a new file shows up in /...
1
vote
1answer
57 views

“Cannot create directory … no such file or directory”

When executing the dockerfile, the command RUN cp -rf roundcubemail-1.2.3/. /var/www/html/ is executed and I'm getting the following error: cp: cannot create directory '/var/www/html/': No such file ...
0
votes
1answer
20 views

Copy only files with certain extension while renaming each file according to the parent folder

I have several directories: ├── folder1.x │   ├── dsferwe │   ├── ewrwr342 │   ├── analysis │   ├── fdsds │   ├── vcxvcxz │   ├── 324322 │   ├── export.asc │   ├── f_random_subfolder.xf │   │   ├── -....
-1
votes
1answer
34 views

Transferring big files from local hard drive to computing cluster by rsync

I have 40 WGS files each one about to 0.1 TB stored in a hard drive next to me. I need to transfer them to my scratch in our computing cluster. I am using windows OS so I am using MobaxTerm for ...
0
votes
1answer
53 views

shell: Different path patterns

What is the difference among following path patterns in Linux ./ e.g. cp ./ [destination-path] ./. e.g. cp ./. [destination-path] ./* e.g. cp ./* [destination-path] ./** e.g. cp ./** [destination-...
3
votes
2answers
527 views

Copying files interactively: “cp: overwrite”

I'm trying to figure out what words does the -interactive shell of cp accepts as input. For your convenience, here's code that sets up files for experimentation. touch example_file{1..3} mkdir ...
1
vote
2answers
41 views

cp file to a directory with a file with same name

Sorry if I missed something in the cp manual, but is there a way to copy a file to a directory where there may be a file with the same name? Something like adding a postfix to the name of the copied ...
0
votes
2answers
21 views

Copy specified subdirectories

I have a bunch of folders in an external HDD and I want to copy a part of them. The folders have the following structure: A001A A003A A004A etc... ...and all the folders contain similar directories ...
-1
votes
2answers
68 views

How do I copy a file to a different directory, but with another file extension?

Let's say I have two directories: orig and backup. Orig contains the file foo. I want to copy the file foo to the backup directory, but with the extension .txt.
2
votes
0answers
42 views

A linux “cp” command equivalent that does read/write threading and buffer sharing for increased throughput?

First, let me address your concerns. I'm copying from one slow drive, to another (different) slow drive. Blocking for reads on one drive until I write to another leaves a lot of room for improvement. ...
1
vote
1answer
22 views

How to use 'find' and 'cpio' to exclude parent directories

I want to copy over all html files in a nested directory but I want to prevent the parent folders above it from being generated as well. That is if my source path is /project/ng1/src/templates/**, ...
6
votes
3answers
794 views

cp works differently on a Mac

I have the following code to copy an entire folder: #!/bin/bash B="H:\pdf2txt" DST_DIR="H:\Test_Folder" cp -r "$B" "$DST_DIR" This works as expected on a windows machine but when I change it to ...
5
votes
2answers
413 views

Copying [use of cp] issue

I have a couple of sub-folders mounted on /mnt. One is /mnt/data, and the other is /mnt/1804iso. The /data includes data folders and files mounted from another disk, and /1804iso includes a mounted ...
0
votes
2answers
150 views

cp command not copying to the correct directory? [closed]

For my classes we have all of our homeworks and assignments in a read only folder so I want to copy all those files (they aren't very big) to my personal folder on ssh login. I so far have been able ...
1
vote
1answer
186 views

No such file or directory during rsync/cp copy command

I am trying to copy my entire shares directory from one server to my current directory. Running the command: rsync -avhP /shares . it will copy 90% of the data to that directory but I am getting ...
0
votes
2answers
196 views

Move or copy without overwrite and check success

Problem: I'm looking for a way to rename or copy a file without overwriting the destination file, if it exists, and then check the success of the move or copy operation. I'm seeking a method that will ...
0
votes
3answers
104 views

Copy files with match prefix AND suffix with shell script

I have a directory with files such as aaaXXXbbb.png aaaYYYccc.png xxxAAAyyy.png yyyAAAxxx.png Now I want to copy all files with prefix 'aaa' and suffix '.png' to a new directory with shell script, ...
3
votes
1answer
238 views

Cp command does an extra copying on different Ubuntu version for folder cloning

Edit: Found a duplicate with solution: rsync -a --delete https://stackoverflow.com/questions/23698183/how-to-force-cp-to-overwrite-directory-instead-of-creating-another-one-inside new script that ...
0
votes
3answers
87 views

Fix space in path from find command [duplicate]

I would like to copy many files with the below command. cp `find /Volumes/DATA/ -name "*.app" -depth 1 2> /dev/null` /Volumes/VMWare/img/ But that doesn't work because if it finds a space then ...
0
votes
2answers
170 views

Rename Files to Same Filename Without Extension with find Command

I'd like to rename a group of files to their same filename but without extension. They are scattered in my home directory and I don't know where they are located precisely, but I do know the extension ...
24
votes
2answers
3k views

Purpose of cp -x (stay on file system)?

If I wanted to stay on the same file system, couldn't I just specify an output path for the same file system? Or is it to prevent accidentally leaving the current file system?
0
votes
1answer
37 views

Copy files according the filename containing a future date in a specific format

I have these files, for example: 20029181109173105_MAN_TDR.PLU 20029181109185001_MAN_TDR.PLU 20029181109185301_MAN_TDR.PLU 20029181109185601_MAN_TDR.PLU 20029181109185901_MAN_TDR.PLU I need to copy ...
-1
votes
1answer
3k views

How to solve error of missing destination file operand after '/sdcard/ngrok/ngrok ' in termux [closed]

I am using termux in my android but I get the following error when I want to copy some data from sdcard to $HOME IN TERMUX the following error shows up: missing destination file operand after '/sdcard/...
0
votes
2answers
38 views

How could I copy the same directory multiple times but with a different name?

I have a directory called 400K that has some files in it, I want to copy this directory multiple times but with different names. I want something like: cp -r 400K 500K 600K 700K I was considering ...
29
votes
6answers
7k views

Why was `cp` designed to silently overwrite existing files? [closed]

I tested cp with the following commands: $ ls first.html second.html third.html $ cat first.html first $ cat second.html second $ cat third.html third Then I copy first.html to second.html: $ ...
0
votes
1answer
52 views

copy directory into another directory multiple times

I'm on a Mac and trying to script out a few things from our build for Xcode. There are dSYM that are directories that you can inspect with Show package contents. In my script that gets run after Xcode ...
2
votes
2answers
65 views

Copy a file a number of times with names that come from a list

I have a list of names and I have a binary file. I want to copy that binary file so that there is one copy for each member of the list. The list is a text file with one name in each row. I keep ...
0
votes
1answer
18 views

Copy a directory structure to ennumerated folders

My folder structure is like this: ej-1/index.html ej-1/js/scripts.js ej-2/index.html ej-2/js/scripts.js ... ej-12/index.html ej-12/js/scripts.js Sometimes I need to re-structure the other ...
1
vote
1answer
170 views

Fedora: cp: Invalid argument while coping a file named with Chinese characters to a vfat filesystem

I want to use cp to copy a file named with Chinese characters to my fat32 usb stick. This is done using a script, so using nautilus is not a solution for me. I do not want to rename the files, too. I ...
0
votes
1answer
51 views

How to find files dynamically and copy them to a directory in linux

Trying to find these files and copy them to a directory (test_dir); abc-1.0.zip kncb-1.0.zip jenk-1.1.zip I would like to find all these files dynamically and copy them to a directory. I have tried ...
0
votes
1answer
27 views

Copying a source directory using the command cp -rsf when target directory exists

On Centos 7, when I use the command: cp -rsf /path/of/source /path/of/target When the target directory exists, files would go to /path/of/target/source. How can I avoid that? EDIT: source and ...
0
votes
1answer
64 views

cp -Tr overwrite behavior

I'm using GNU coreutils I have a directory foo containing a file file1 and a directory bar containing file2. If I now do a cp -rT foo bar, bar will contain both files instead of getting overwriten ...
1
vote
1answer
8k views

cp: cannot create regular file: Permission denied

I am running a PHP script on my Apache server and from the script I need to copy some files (to run a Bash script that copies files). I can copy to a directory /tmp with no problems, but when I want ...
3
votes
1answer
112 views

Can rsync pick up where an interrupted cp left off?

If I use cp to copy a very large file over the course of several hours and decide to stop the operation, can rsync be used to complete the operation at a later point without needeing to re-write data?
1
vote
1answer
36 views

find files with particular attributes, rename them to their directory name, copy them elsewhere

It won't look like it, but I've spent 3+ hours trying to figure this out... I am trying to identify files in all subdirectories of a parent directory with particular attributes (name and size) then ...
2
votes
1answer
122 views

Overwrite symlink with original file

I have a directory with some symlink file, for example: /home/user/symlink/$(*symlink_file_name1*).mkv /home/user/symlink/$(*symlink_file_name2*).mkv And I have another directory with the original ...
7
votes
6answers
1k views

sh recursive copy (cp -r) - How to exclude subfolder

I need to run a remote script using ssh via Ruby (net/ssh) to recursively copy a folder and exclude a subfolder. I am looking for the fastest way to do it so rsync is not good. Also, I understand that ...
2
votes
1answer
469 views

Use rsync to only copy files that have changed

Right now I have these commands: my_dir="$HOME/foo/bar"; rm -rf "$my_dir/WebstormProjects/"; rsync -r --exclude=".git" --exclude="node_modules" "$HOME/WebstormProjects/" "$my_dir/WebstormProjects/" ...
-2
votes
1answer
88 views

cp -r <Folder Name> .<Folder Name>

I run the command cp -r <Folder Name> .<Folder Name>. It have done something, but I cannot find it. Example: cp -r Agent .Agent.old # (There is a dot symbol on the 2nd folder name)
0
votes
1answer
535 views

error: cp: cannot stat ‘release\\-1.0.0\r.jar’: No such file or directory

I have a file "release-1.0.0.jar" in the current working directory, and I'm trying to copy it to a directory "release_dir". export t_version="1.0.0" mkdir -p release_dir cp release-${t_version}....
1
vote
1answer
52 views

Copying files based on input list, special characters in file names

This is based on the question here. Problem: I have a .txt file listing file names I want to copy to the folder newfolder in the shell (Mac Terminal). Approach, where filelist.txt contains file ...
1
vote
2answers
167 views

How to copy a folder by overwriting an existing folder and delete all the old content in Linux?

I can use rm to delete the old folder, then use cp to copy the new folder. But how to do it in one go?
1
vote
3answers
973 views

Linux 'cp' copies symlink instead of target file

In my directory I have 2 files: a text file and a symbolic link to that text file. base_v21.txt -> base_v001.txt base_v001.txt When I try to copy base_v001.txt using the following command: # cp ...
-1
votes
2answers
3k views

COPY file from one server to another [closed]

I have to get some files from production to DEV server. SCP command gives the timeout. I do not have ip and I connect to the server using ssh command as below. ssh komz-admin@pxxxxxxx04.corp.xxx....
0
votes
2answers
60 views

answering command automatically - performing cp operation between answers [closed]

The idea is that I want to execute a command, then it asks for a file name to process, and after it is done with processing, it outputs an image with the name prediction.png, it asks for the next ...
2
votes
1answer
39 views

Why does cp need -r while mv doesn't? [duplicate]

To copy a directory and its contents cp requires a -r switch. To move a directory and its contents mv does not require a -r switch. What is the reason for this? EDIT: Don't worry. Despite searching,...