Questions tagged [cp]

cp - Command-line tool to copy a file

Filter by
Sorted by
Tagged with
2
votes
0answers
42 views

Using cp to copy ~/.config to an external drive but getting “cannot create regular file…File exists” errors

The command is simple enough, executed while in a subdirectory of /mnt/e, an external drive: cp -r ~/.config .. Every time, every time I run it, the same set of files refuse to copy properly: cp: ...
1
vote
1answer
17 views

Copy file with changed content

I'm writing bash script where I need to store some files as a .bak files and change it content at the beginning(using sed for that). I'm looking for better way to write it down for my bash script. cp ...
-1
votes
1answer
60 views

How to copy files one by one to different folders?

In a directory I have files with the names: 01.txt 02.txt 03.txt In the same directory are folders with the names: 01.abc 02.def 03.ghi I need a command to copy the files to the folders one by one,...
0
votes
1answer
33 views

Shell script cp command to a folder that will constantly change name

I have a script that downloads a folder. The folder has a fixed name with an ever changing number as a suffix, e.g. fixed_name_450. Each time I run to script the downloaded folder will have a new ...
0
votes
1answer
46 views

Missing destination file operand

I am beginner as far as Linux is concerned and therfore ran into trouble with the following command. $ cp VRP/share/ViennaRNA/bin/*. The error I got is as follows: cp: missing destination file ...
1
vote
0answers
40 views

cp - Does not recognizning accent characters [duplicate]

I have written a simple script, to copy some files, and change there name: #!/bin/bash for directory in ./../old_files/*; do DIR_NAME=$(basename $directory) for file in $directory/*; do ...
0
votes
3answers
78 views

Copying a list of files

I have a directory which has plenty of files which need to be copied over to another directory. Remember, not all files need to be copied, only some of them. Is there a way I can come up with a script ...
0
votes
1answer
40 views

How to select a path in a find […] -exec cp {} dest_dir \; command?

I'm having a hard time trying to limit the path with find. I have this command find ${DIR_PATH} -type f -name ".py" -exec cp --parent {} ${DEST_DIR} \; Which give me this output : ${DIR_PATH}/a/...
1
vote
3answers
44 views

Copy files from one path to another except .zip files [closed]

I need to copy all files from one UNIX path to another within the same server. However, there are some .zip files I want to exclude while copying. How can I achieve this using the cp command options?
1
vote
1answer
112 views

COPY failed: stat /mnt/sda1/var/lib/docker/tmp/docker-builder006125699/src: no such file or directory

When I run this command docker build -t hello-world . I got this kind of error...what should I do...How to copy file to /var/www/html/ Sending build context to Docker daemon 2.048kB Step 1/3 : ...
0
votes
2answers
29 views

Copying diff results files

I have two folders - Folder A and Folder B. I compared the files from both folders using diff command. Now after finding that certain files are only available in Folder A and Certain files in Folder ...
1
vote
2answers
81 views

How to avoid copying “..” while using cp command in terminal? [duplicate]

I am using CentOS7 and when I use command cp /root/test/.* /root/test1 it also copies .. which copies all the files and folder in the parent directory of the source. How to avoid copying . and ..?
4
votes
1answer
85 views

Move/copy millions of images from Macos to external drive to ubuntu server

I have created a dataset of millions (>15M, so far) of images for a machine-learning project, taking up over 500GB of storage. I created them on my Macbook Pro but want to get them to our DGX1 (GPU ...
1
vote
2answers
39 views

Overwrite or don't copy?

I'm trying to copy a file only if it already exists, not if it doesn't, basically overwrite only on Linux. Does anyone know a solution? I basically need to "look" for a folder then if a file exists, ...
1
vote
1answer
75 views

cp runs from command line but file not found from script [duplicate]

I have a script to reorganize my directory structure that contains: files=./*"$pattern"I{"$ifirst".."$ilast"}.ext cp ${files} ../"$pattern"/"$i"/ When I run the script, I get an error: ./*S6I{001.....
0
votes
2answers
58 views

Copy every 10 files from source into a target directory using cp

I have 110 large files inside a directory. But I cannot copy them at once since the system gets timed out after 50 min. I want to copy files 1 to 10, next 11 to 20, next 21 to 30, and so on. The order ...
1
vote
0answers
32 views

I have a directory of 110 large files. I want to copy them in the batch of n (e.g., 10) to aws s3 [closed]

I have 110 large files inside a directory. But I cannot copy them at once since the system gets timed out after 50 min. I want to copy files 1 to 10, next 11 to 20, next 21 to 30, and so on. The order ...
2
votes
1answer
41 views

How to write a script to move files with a specific name from folder “A” to folder “B” in my Google drive?

How can I write a script that moves files with a certain name from a certain folder to another certain folder in my Google drive? Example: I have a folder named 'A' with three files named 'X', 'Y', ...
-6
votes
1answer
71 views

What is the meaning of -r and -R in copy command?

I read that they stand for recursively in the man page. However, I am not sure what their role is in the command. When I tried to copy some empty directory into another directory with, $ cp EMPDIR ...
0
votes
1answer
46 views

What happens when you copy a hardlink?

Imagine I have a file something/a.txt, which I hardlink from b.txt. Now, if I cp b.txt c.txt, is c.txt a hard link to a.txt, or is it a copy of the contents of a.txt?
1
vote
1answer
33 views

Attempting to only copy files that have changed within the last day while maintaining folder structure

I'm attempting to find and copy files that have been modified within the last day. While doing that I'm trying maintain folder structures under dir1. There are many subdirectories under dir1 and data ...
0
votes
0answers
34 views

Can I specify a size space while using mount command?

I mount a *.img file, and want to copy some new files into it. But there is not enough space for me to place new files. Can I specify more size space while I use mount. ./Image: No space left on ...
0
votes
2answers
25 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 ...
5
votes
1answer
494 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
51 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
148 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
113 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 /...
2
votes
1answer
474 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
26 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
37 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
57 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
799 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
130 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
22 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
260 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
54 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
37 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
960 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
539 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
318 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
422 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
847 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
282 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
262 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
127 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
255 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
4k 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
51 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
8k 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
52 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 ...