Questions tagged [cp]

cp - Command-line tool to copy a file

Filter by
Sorted by
Tagged with
0
votes
1answer
61 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
16 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
29 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
50 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
41 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
117 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
18 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
123 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
20 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
30 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
18 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
998 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
53 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
30 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
85 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
185 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
23 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
48 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
28 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
50 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
17 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
54 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
32 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
34 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
166 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
75 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
38 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
25 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 |-- ...
0
votes
1answer
41 views

how copy and move files in Ubuntu Linux

Trying to use the copy move and remove commands in Linux but always get error messages. There are three symbols in Linux directory structures that I'm having a hard time with These are ".", "~", and ...
0
votes
1answer
34 views

Write permissions in GNU/Linux [duplicate]

As far as I know, if I set write permission to a directory (+w), I will be able to copy files inside and the execution permission to a directory (+x) allows me to list the content of it. I get ...
0
votes
2answers
94 views

Using cp's interactive option for saving text from stdin

In an interactive shell script I'd like to save the output of a command to a file like in $ echo "Hello, World" > test.txt but prevent test.txt to be overwritten if it already exists. So I ...
0
votes
1answer
11 views

Copying a list of test/path/to/files to list of prod/path/to/files

I would like to copy a list of files in the form test/path/to/file/filename.xyz to their corresponding production path prod/path/to/file/filename.xyz. If the test path and the prod path are the same ...
1
vote
0answers
40 views

scripting: how to cp (or rsync) same files (and filenames) with autorenaming and mantaining .ext

I want to write a simple bash script (for loop). After obtaining a list of wanted files, eg:find /start/* -iname "*.txt" > txt.list I'd like to copy all of them inside an unique destination with ...
-2
votes
1answer
88 views

How to match x number of characters of a file name with cp?

I try to use cp to copy a file with a partially dynamic name: cp google71bg2z2850dafxa3.html DESTIONATION By principle, the google part of the file name is consistent, but the 71bg2z2850dafxa3 (16 ...
1
vote
0answers
102 views

Alternatives to dd to read/write to a disk?

I'm using cp to read/write from an SSD drive but is not fast enough. Then I used dd, which is fast, especially with the drive unpartitioned. But I ran into errors like there is no space left on ...
23
votes
3answers
4k views

Why is cp's option not to overwrite files called --no-clobber?

cp is a massively popular Linux tool maintained by the coreutils team of the GNU foundation. By default, files with the same name will be overwritten, if the user wants to change this behaviour they ...
1
vote
0answers
34 views

Where can I find the official document on advanced cp command? [duplicate]

I want to copy all contents in folder A(but not include A itself) to another folder B recursively, and overwrite any existing files or folders with the same name. Originally I plan to use the ...
34
votes
1answer
3k views

Is `cp --no-clobber` vulnerable to race condition?

The man page for cp(1) says --no-clobber do not overwrite an existing file However, wouldn't the following scenario be possible? cp checks the file existence, let's assume the file doesn't exist (...
0
votes
1answer
106 views

cp / rsync - Overwrite if smaller, backup original and then overwrite if larger

I have files in Folder A than I want to copy in Folder B. Folder B contains some files by the same name. Timestamps on all files are the same and I want to overwrite and backup larger files of the ...
1
vote
1answer
48 views

What happens if a file is renamed during a copy operation using cp on linux?

So I want to use... cp /var/log/somelogs/* ./temp ... to copy some log files to a temporary folder and analyse them. The problem is that the process generating the log files isn't under my control ...
0
votes
1answer
37 views

How to update a same file to a destination folder which has different directory structure?

Suppose I have folder structure: folder: a.text folder_2: folder_3: a.text How I can sync this file without mentioning the full destination path? I have tried rsync -hvrPt folder/* folder_2 ...

1
2 3 4 5
13