Questions tagged [cp]

cp - Command-line tool to copy a file

Filter by
Sorted by
Tagged with
0
votes
1answer
32 views

Need cp -ax alternate for Solaris

On my Linux host; this cp command helps copy files and folders both while preserving the timestamp and permissions cp -ax <source file/folder> <destination> Need similar command for SunOS ...
1
vote
2answers
49 views

Shell script on Raspberry Pi fails to copy files from usb0 to directory

I am trying to write a shell script to copy specific files from an archive USB thumb drive to my Rasberry Pi 4b. The script is, in my opinion, brain dead simple. cp /media/usb0/archive/file1.zip /home/...
0
votes
4answers
37 views

cp files with pattern with middle directory variable

I have a directory l ── 10020 │   ├── live │   │   ├── 211231.jpg │   │   ├── 211231_BB.txt │   │   ├── 448378.jpg │   │   ├── 448378_BB.txt │   │   ├── 460830.jpg │   │   └── 460830_BB.txt │   └── ...
0
votes
0answers
33 views

how does the cp - f work in Unix? [duplicate]

I was reading about the cp command in unix and one of the options is: cp -f : force copy by removing the destination file if needed so I wanted to test this to see how it works, I did the following: ...
0
votes
2answers
38 views

Using xargs to copy directories

I'm trying to write a script to copy a set of directories that were created today to another directory. I'm currently using: find /test/downloads/ -mindepth 1 -maxdepth 1 -type d -mtime -1 -printf '%f\...
5
votes
2answers
154 views

If cp's destination path turns out to be a directory, how do I avoid mistakenly creating files inside that directory?

My understanding of cp src dest is: If src is a file and dest doesn't exist, but its parent directory does, dest is created. If src is a file and dest is a file, dest is overwritten with the contents ...
0
votes
1answer
74 views

How do I copy variously named files with the same extension to all have a standard file name?

I have variously named files such as in different subdirectories e.g.: a/apple.txt b/orange.txt c/pear.txt How do I copy them to have a uniform name (fruit.txt) in their respective directories so the ...
0
votes
2answers
23 views

Copy file in multiple (variable) folders

I want to copy files in multiple subfolders with variable subfolder names. Example: mkdir rootdir mkdir rootdir/dir1 mkdir rootdir/dir2 mkdir rootdir/dir3 touch rootdir/dir1/foo.txt touch rootdir/dir2/...
0
votes
1answer
28 views

Restore ENTIRE system ROOT / (CLARIFICATION)

I recently had to restore the disk with borg. So via live linux, I entered my disk file system, deleted everything (root /), and restored a backup of a specific date. Now I ask myself: do you need to ...
0
votes
1answer
56 views

Copy and rename files recursively using part of folder name for new name

I'm trying to recursively copy a folder of files containing .csv extensions and rename them while copying them into a single folder. I'm close except for the file renaming which eludes me. Can anyone ...
-1
votes
1answer
70 views

Make sure that the “cp” command is executed properly

I make a backup copy of my files with cp command as described in this topic (Copy files in Linux, avoid the copy if files do exist in destination): https://superuser.com/a/1377730/1008457 Command is: ...
0
votes
1answer
53 views

Does the 'cp' command continue to copy all files if it has a permissions problem with one file or folder?

In OS X Mojave / bash, I am in my home directory copying all files using the cp command from the directory ~/Pictures/ to ~/Dropbox/Pictures/ and as often happens when copying without sudo on *nix, I ...
1
vote
1answer
24 views

Copying to external device messes up special characters in NixOS

I have a DAP (like an mp3 player) and I am trying to sync up the contents of one of the folders on my pc to the DAP. This does work almost as intended, but something weird is happening to the ...
0
votes
1answer
71 views

Storing find results in variable then passing to cp?

I have a need where I must work with a set of files based on time elapsed (as I do not have control over when new files are added to the remote directory). I must do several operations with this set ...
0
votes
0answers
25 views

I get this error when copying some files with rsync: “rysnc: read errors mapping “…” input/output error” - I can open and watch the file in VLC

I am using rsync to clone hundreds of video files to another hard drive. There were 3 files which had the exact error as below: rsync: read errors mapping "/var/run/importcopy/tmpdir/dev/da1s1/...
1
vote
1answer
31 views

How to copy a file and change destination file permission in one step?

I am writing a shell script to do some complex task which is repetitive in nature. To simplify the problem statement, the last step in my complex task is to copy a file from a particular path (which ...
0
votes
0answers
17 views

Can someone please explain in lay-mans terms what cp -arxpf does?

I'm inept at understanding the manual apparently. I read 'sudo cp -arxpf...' Can someone please explain to an idiot (me) what the -arxpf options do in the copying? Thanks in advance, Rob
1
vote
3answers
51 views

How do I copy a file without pasting immediately from terminal? [duplicate]

When using the command "cp", I need to know where exactly I want to paste my file. Often, I have to copy a file but without having to paste immediately or sometimes I do not know where I ...
2
votes
1answer
42 views

cp -r: trigger “No such file or directory” error instead of creating “dst”

Case 1: If dst does not exist, then cp -vr src dst creates dst and copies all the content from src to dst: $ cp -vr src dst 'src' -> 'dst' 'src/t0.c' -> 'dst/t0.c' Case 2: If dst does exist, ...
0
votes
2answers
336 views

Disc quota exceeded, cannot create, copy, or move files… is there another way?

I'm sshing into a remote server to complete some work. I tried to edit a file in nano, but realized, after saving and exiting, the file (quite a lot of work) was empty. Apparently, my disc quota has ...
0
votes
0answers
19 views

pause file copying using 'cp' [duplicate]

Copying a file with cp, is there a way to pause the operation? NB: copying a single file or copying a large number of files
2
votes
1answer
138 views

Simple cp command not working (inside shell script and submitted using sbatch on a cluster)

I am working on a cluster running RHEL and I submit jobs using the following command. sbatch MyScript.sh The content of the MyScript.sh are as below. #!/bin/sh # .... # Other SBATCH related commands ...
1
vote
0answers
21 views

Diskless root filesystem starts to break when copied to a new location

I am pxe booting using nfs to get a diskless cluster. When doing testing I wanted to make a copy of the directory used by the nodes to mount the linux root filesystem. But after copying the file over ...
0
votes
0answers
18 views

CentOS cp shell glob operation with asterisk (*) fails [duplicate]

In a CentOS shared web hosting environment (I don't know a CLI way to check CentOS version) with Bash 3.2.52 I tried the following command: cp "${domain_dir}/google*.html" "${...
0
votes
2answers
31 views

I copied a file into my VM, but the folder is a regular file

I'm new to Linux, and I'm trying to untar the following file, so I moved from GCS to the Virtual Machine with the following command gsutil cp gs://ghtorrent_datadump/mysql-2020-07-17.tar home/...
0
votes
2answers
20 views

copy a directory into another directory and create intermediate directories

I would like to copy the whole /usr/share/zoneinfo/ directory into /var/www/clients/client1/web5/./usr/share/zoneinfo/. (The /./ is added for clarity and formatting purposes) The directory /var/www/...
6
votes
3answers
1k views

Effect of 'cp /dev/zero a' when file a exists

If a exists and I type cp /dev/zero a can I be sure the old contents of a will be overwritten, or will I simply get the equivalent of rm a cp /dev/zero a PS. I am not suggesting that this is the ...
1
vote
2answers
59 views

Copy file recursively to all deepest subdirectories

I'm trying to copy a single file to all of the deepest subdirectories in a tree structure. Imagine it looks like this: bar dir1 | | | +--dir2 | | | +--dir3 | +--dir4 | | | +--...
0
votes
1answer
45 views

How can I copy directory itself with attributes?

I would like to copy only attributes of a directory to existing directory. for example... # mkdir /var/tmp/target-dir # ls -ald /var/mail drwxrwsr-x 2 root mail 4096 4月 27 2018 /var/mail my image ...
0
votes
0answers
32 views

cp copies from hard drive to USB 3.0 stick with transfer speed below 1.7MB/s!

Aspire One Cloudbook 14 (A01-431-C8G8) Linux kernel 4.19 Debian 10 Hi: I have a USB 3.0 pendrive (stick) plugged into a USB 3.0 slot in the laptop. I copied (cp) all files in one of the laptop ...
4
votes
0answers
88 views

What should 'cp -r srcpath/.. dstpath' do?

Consider the following: /tmp$ mkdir -p src/{a,b} dst/dstsub; touch src/{a,b}/hello /tmp$ tree src/ dst/ src/ ├── a │   └── hello └── b └── hello dst/ └── dstsub Now run /tmp$ cp -r src/a/.. dst/...
2
votes
1answer
207 views

Why does 'cp -r ../* .' work but not 'cp -r .. .'

If I have the tree: . ├── child ├── dir1 ├── dir2 ├── dir3 ├── file1 ├── file2 └── file3 This is the result of issuing these commands within child: This works and copies all files and directories: cp ...
0
votes
0answers
46 views

single command to `mv`/rename/move a file and set the user, group & permissions?

I can copy a file with cp. But with install I can copy a file, and set the owner, group and permissions on the new destination file, which is useful. With mv, I can rename/move a file, which (if it's ...
0
votes
1answer
21 views

Configuring an external harddisk for Linux

I've purchased a new external hard disk for using in Linux and I have two questions: one about the permissions and other about copying data. Here are them: I've formatted the disk using GParted (I've ...
1
vote
0answers
34 views

Why cp and mv behave differently in bash script than command prompt? [duplicate]

I have cp and mv commands withaliases preset in my system. [root@IMSSA ~]# which cp mv alias cp='cp -i' /bin/cp alias mv='mv -i' /bin/mv [root@IMSSA ~]# If I try to replace a file, ...
0
votes
0answers
26 views

copying file inside shell script is producing error

I've been trying to copy large number of files from one partition to another. The command works smoothly directly in the shell but once I put it in a script I get this error: /media/My.../source/...
-1
votes
1answer
25 views

i want to copy a directory from my local system to a remote machine using rsync [duplicate]

I have a file on under my local machine with the name codes.examples and I want to copy it to a remote machine under the directory ~ahmet using the command rsync and ssh knowing that remote machine ...
0
votes
1answer
59 views

how to copy files without breaking utf8 filenames in ubuntu 8.04?

I have a very old PC which is unable to run pretty much anything. It previously used Windows 7, but now everything I try just makes it reboot. I, finally, managed to get access to it by running ...
0
votes
2answers
29 views

How do I copy a file within a subdirectory into an adjoining subdirectory?

My hierarchy is MyPDB -(5rea,5res,5rez) in which each 5rea, 5res, .. contain a directory called MD which contains a file named production_10ns.out. I want to copy production_10ns.out from each MD ...
1
vote
1answer
51 views

How to copy specific subdirectories to a new directory?

I am trying to copy specific subdirectories (and the files contained in them) to a new directory. Assuming I am in the first directory (dir0/), this contains a number of subdirectories named 000/, 001/...
0
votes
1answer
20 views

Used `sudo cp -r` instead of `sudo nautilus`, can't access files without using `sudo`. How do I copy them ignoring privileges?

I'm a relatively new Linux user and was transferring over to a new computer, so I decided to copy some files (some configs, downloads, and home files) over to a hard drive (from a previous laptop). ...
0
votes
2answers
55 views

Copy file(s) into specified directories

I have a lot of files with names in the same format – four alphanumeric characters, .pdb, and a digit – and I would like to copy them into corresponding directories. For example, in the directory ...
0
votes
1answer
36 views

Reflink copy diff

I want to make a behaviour like btrfs send and btrfs receive, but on a per-file basis. As far as I see it, I can use cp -ax --reflink=always to make a "snapshot" of the file. Let's assume that two ...
0
votes
0answers
10 views

Unable to copy files from VMFS mount

Using vmfs-tools and the following syntax: vmfs-fuse filename.E01 /mnt/mounted_place works fine. While using ll -h I am able to view the contents of the mounted drive. My goal is to move all the ...
0
votes
0answers
42 views

find exec cp - copy files without overwriting duplicates

I've got a few directories with matching file names: Foo/ one.pdf two.pdf three.pdf Bar/ one.pdf two.pdf three.pdf Baz/ one.pdf two.pdf three.pdf ...and I want to move all files ...
0
votes
0answers
24 views

How to copy files from linux rhel6 to another rhel6 (which are not connected)?

How to copy files or folders from linux rhel6 server to another (which are not connected) with same file or folder properties (especially symlinks) using zip? The only way is FTP to server1 and copy ...
4
votes
3answers
217 views

What is the command to copy, read and remove file in linux

I want to copy some files from root directory (/var/log/) to home directory(home/test/copyfromlogs/) and after that i want to remove those files from root directory. The files I want to copy are ...
3
votes
2answers
79 views

How do I copy files across/outside symbolic links? (dest) [duplicate]

Suppose I have a file system like this: /home/me/dir1/dir2/dir3/dir4/dir5/dir6/file1 Then in /home/me/dir1, I create a symbolic link: $ cd /home/me/dir1 $ ln -s /home/me/dir1/dir2/dir3/dir4/dir5/...
1
vote
1answer
41 views

cp with spaces and special chars works fine on the terminal but not in the script

I am trying to write a script to find a file and copy it to a particular folder. The file name has spaces and other special characters. a=$(ls ~/Downloads/ | grep $1) a="'$a'" a="~/Downloads/"$a ...
0
votes
2answers
28 views

Copy files from multiple directories, if their name appears in a list, into a single directory

I've got a huge tree of folders, each with multiple subdirectories going down around 3 levels. Here's an example with just one level: $ tree . |-- AB.txt |-- CD.txt |-- destination_folder |-- ...

1
2 3 4 5
14