2022 Developer Survey is open! Take survey.

Questions tagged [cp]

Questions relating to the Linux 'cp' command.

Filter by
Sorted by
Tagged with
0 votes
0 answers
49 views

unable to copy files from ssd to hdd in ubuntu 20.04

I'm trying to copy media files like .mp3,.mp4, .mkv etc. from my ssd to hdd as to save time complexity of ssd but unable to do so. Everytime I try to copy or move files it shows me this error "...
user avatar
0 votes
1 answer
141 views

Why doesn't 'sudo cp' copy files in the /sys directory?

I want to make an exact copy of the /sys directory, and tried the following command: sudo cp -ra /sys ~/Documents/dir1 It does not work as I expected... I get a lot of error messages such as: cp: ...
user avatar
  • 469
1 vote
1 answer
57 views

How to automatically open a file that has a dynamic filename

I'm trying to make an automation process, my workflow generates a file automatically, this file is named based on a timestamp and a public key. Example of the file name : UTC--2022-03-07T10-53-08....
user avatar
0 votes
1 answer
34 views

Is there an easy convertor between dpkg --print-architecture and uname -m for generic scp?

I want to copy files that relevant to my machines (x86_64 / aarch64) from remote machines. I want to use: scp user@host:*$(uname)* . to copy both wheels and .deb files, e.g.: name-x.y.z-cp36-cp36m-...
user avatar
0 votes
2 answers
108 views

Copy all from a folder into the project root directory

I have a web project with the following structure: application/ dumps/ nginx/ logs/ .git/ docker-compose.yml Dockerfile README.md .gitignore For several reasons, I would like to dissolve the ...
user avatar
0 votes
1 answer
35 views

How to move a matched id of mat files in different folder

I have Matlab (.mat) files in a particular folder. In a text document, I have some IDs list marked as 0 and 1. First I need to match the IDs and separate the mat files that are marked as '1'. For your ...
user avatar
  • 1
0 votes
1 answer
66 views

Accidentally used "cp /file /dev/sdb1"

I'm about to cry, in need of your help... I'm new to linux. I was trying to copy a Windows10 iso to my external HDD. I wanted to use cp command. I saw that my external HDD was sdb1. So I just used cp /...
user avatar
0 votes
1 answer
578 views

How to copy multiple files to a new folder in a new path in one command?

[These are the files I want to copy over][1] Example command I have tried but does not work: cp permanent_waiver_* /existingpath/newfolder1/newfolder2 This would give me error like no such file or ...
user avatar
  • 1
0 votes
2 answers
70 views

Copy files based on date with structure of directories

I have commend: find /source/ -type f -newermt '18 dec 2020' -exec cp -t /target/ {} + This commend copy only files, without structure of dirs, but i need files with his parent dir. Second thing is ...
user avatar
0 votes
2 answers
69 views

How to copy files into a new file

How to copy files from one file to another file that has contents I want to keep? In other words, I want the contents of file1 to go in file2 but the info in file1 to be added to the existing stuff in ...
user avatar
0 votes
1 answer
223 views

I would like to maintain a mirror copy of many files and directories using cp, but I cannot get it to function (similar to MS XCOPY with switches)

I am trying to copy SOURCE to DESTINATION, so that DESTINATION is identical to SOURCE. Note that SOURCE is 89GB with 26k files and hundreds of folders, so it is not practical to do an entire copy when ...
user avatar
1 vote
1 answer
144 views

Rename file names with a parent directory name

I want to rename my files recursively, ending with *.fna.gz with the parent directory two-step-up i.e. "Aspergillus_neoniger". You can see the subdirectories details in this image tree ...
user avatar
  • 43
0 votes
2 answers
640 views

Way to speed up cp -a (using cp -a within a thumb drive is very slow)

When using a thumb drive with a persistent operating system, it happens that the persistent partition casper-rw gets corrupted, if one pulls out the thumb drive too early after shutting down the ...
user avatar
2 votes
2 answers
78 views

Move all JPGs and rename them into one directory

.Hi. I have a bunch of jpgs in 100s of subfolders , I know I can move them all with this command find -type f -iname "*.jpg" -exec mv -av {} /home/root/private/pics/ \; But my all my jpgs ...
user avatar
0 votes
0 answers
391 views

cp: cannot stat '{1..112046}.pth': No such file or directory

I am using Ubuntu 16.04. I am trying to copy the range of files from one directory to another directory. cp {1..112046}.pth path/to/destination_folder While being inside the source folder. But it ...
user avatar
2 votes
1 answer
133 views

cp .* /home/name erased all files in /home/name

A while ago, I got a new ssd for my laptop, so I dd'd everything onto the new drive, and used it for a while without issue. I decided to put the old drive back into my laptop, and put newer ssd into a ...
user avatar
1 vote
0 answers
221 views

Problems copying to SD card

I am trying to automate copying a large file (25MB +) to an SD card, but it's not working - So I've tried in the command line... cp /tmp/MIRROR/myfile.db /run/media/mmcblk0p1/MIRROR/ but this throws ...
user avatar
  • 111
0 votes
1 answer
157 views

Stop `cp -al` trying to link to hidden files?

I would like to make a "hard-links" copy of my home directory before syncing my home directory with another computer with unison, just in case unison goes awry. But cp -al tries to link to ...
user avatar
  • 2,435
1 vote
1 answer
96 views

why doesnt this bash script get all the files?

I have a large folder with subfolders of pdf files. I want to get all the pdf files (290 of them) and get them into one directory. (I thought that would be simple.) so that I can concatenate them into ...
user avatar
  • 13.9k
-3 votes
1 answer
79 views

How can I copy a file n Linux terminal, without pasting it? [closed]

I have run this in my Linux machine # cp file . Is that command copying file1? Is there anyway to paste file1 in other folder after using above command (whitout cp file1 path/to/file)?
user avatar
8 votes
2 answers
3k views

cp recursive with specific file extension

I am trying to copy all .odt files including those in subdirectories. cp -r ~/Documents/* ~/copies # works as expected cp -r ~/Documents/*.odt ~/copies # does not work as expected The first line ...
user avatar
  • 115
0 votes
2 answers
1k views

Copy files and set owner/group to the owner/group of the destination directory

I have a script used in different environments. This scripts uses sudo cp to copy files (sudo otherwise it has no access). But sudo cp creates the files with the wrong owner. It cannot keep the owner ...
user avatar
0 votes
1 answer
1k views

sudo: unknown uid 1000: who are you? (sudo completely broken)

I am new to Linux environment and I need little guidance. I made a mistake while setting up the password and username of mosquito MQTT broker on AWS ubuntu 18.04 instance. I have altered the contents ...
user avatar
1 vote
2 answers
237 views

How to copy files with certain permissions to directory

I'm trying to make a copy of files with read and write permissions for the owner only, and then redirect that file to a directory named $dirA. I tried to use this command: cp (ls -l ~| grep -type f-...
user avatar
0 votes
1 answer
198 views

What is cp command with tilde in final part of destination? [duplicate]

For example: sudo cp /etc/apt/sources.list /etc/apt/sources.list~ With this command I not see any changes. What does the final tilde do?
user avatar
0 votes
0 answers
25 views

TAB does't work properly with `cp` command when using environment variables [duplicate]

Question When using cp command with environment variables, why pressing TAB for auto-complete doesn't work properly? Description I have a directory $HOME/Music; I want to copy a file from within this ...
user avatar
  • 157
0 votes
1 answer
1k views

Copying a .bashrc file from one user's directory to another

I am trying to copy a bashrc file from one folder to another. For example, the bashrc file is in Data/user/user1 and I am trying to copy it to Data/user/user2 with the following cp command: cp Data/...
user avatar
1 vote
2 answers
246 views

Need help using the SCP command line

I have a server with Ubuntu 18.04 I want to transfer my website to a new server. Here are my questions : How to copy files with png extension ? I tried the following command line but it doesn't work : ...
user avatar
  • 13
1 vote
1 answer
99 views

File has weird name, and cannot be found after being copied

Technically all I'm trying to do is substitute one file with another using a script: echo "PASSWORD" | sudo -S rm paper_RPG.jar cp /home/network/PaperAndWaterfallUpdater/paper.jar paper_RPG....
user avatar
0 votes
0 answers
1k views

mv: missing destination file operand when special characters are involved [duplicate]

This one's silly. I saved my vim session with :Obsess -S Session.vim instead of :Obsess Session.vim, so now I have a -S/ Session.vim file in my project and can't open it with vim as the following is ...
user avatar
  • 133
0 votes
1 answer
91 views

simple cp command problem " i try to copy only "

cp: 'test.txt' and 'test.txt' are the same file asadzoot@asadzoot-Vostro-14-3468:~/cnc/q1$ cp test.txt home/asadzoot/cnc/q1/ cp: cannot create regular file 'home/asadzoot/cnc/q1/': No such file or ...
user avatar
1 vote
1 answer
17k views

Copy all files from one folder to another in linux

I want to copy only files not folders from one folder to another in linux. I am using the following command cp sourceDir/* destDir The above command does copy all files to destDir but the command ...
user avatar
0 votes
2 answers
62 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 ...
user avatar
  • 101
2 votes
3 answers
361 views

How to copy 12GB file from Ubuntu 19.10 to Android if My RAM size is 8GB

I tried different options to copy a 12GB movie from Ubuntu to Android (connected as a Camera for reliable connection, with mtp situation even worse), but surprisingly for me there is a RAM+SWAP ...
user avatar
0 votes
1 answer
193 views

simple question cp (command) [duplicate]

my problem is ''cp'' command I can't understand why I can't copy a simple text file for example: I have on the desktop two files "fis1" and "fis2" and in "fis1" I have "perfect" (text file) and I ...
user avatar
5 votes
2 answers
2k views

sh alternative to bash cp {file,file}

In a script, if I put #!/bin/bash at the top, this will work fine: cp directory/{foo,bar} destination However, with sh, this will give the error 'no such file or directory'. In sh, is there another ...
user avatar
  • 153
2 votes
3 answers
980 views

Copy over a large number of files with new names

I have a large number of files (tens of thousands) I need to copy over from /dir1 to /dir2 but the name of the file must change as such: OLD NAME ---> NEW NAME filename.txt ---> bob_filename_1253....
user avatar
  • 21
-1 votes
1 answer
717 views

script to copy multiple files from multiple directories to one of the folder/directory

I'm having five different directories in the home path which contain some files in all directories, as shown below. home/dir1 contains: abc121219.txt kucj.txt gtuj120518.txt gdkmcg.txt such.txt ...
user avatar
1 vote
1 answer
287 views

Copy all files from subdirectories and subsubdirectories to main directory with modifying file names by adding prefix of all parent directories

Following these two posts: Move files to parent directory, prefixing file name with former subdirectory name recursively add directory name to file name I would like to do the same but with copying ...
user avatar
5 votes
4 answers
18k views

How can I copy the contents of a child folder to its parent folder using command line?

I have this directory structure: parent_folder/child_folder/ I want to copy the contents of the child folder to the parent folder, but I don't know how to do it with cp.
user avatar
-2 votes
1 answer
107 views

Copy files such that individual files gets copied to the folder having file name as a string within complete folder name [closed]

I am using Cygwin as Linux shell, I have following contents in my current working directory: Files : Abc.dat 123.dat 456.dat Directories: W_Abc_w W_123_w W_456_w Now I want to copy files as ...
user avatar
4 votes
4 answers
5k views

trying to CP a directory to /dev/null

What I'm really tring to do, it verify the the data on an external drive is still readable. I thought the simplest and surest way to do this would be to copy everything to /dev/null. It works great ...
user avatar
1 vote
0 answers
1k views

Does copying files from EXT4 filesystem to NTFS lose permissions?

I recently attempted to back up my /home/user directory while removing ecryptfs from my system. I didn't have enough space on my Ubuntu EXT4 SSD so, not thinking, I used sudo cp -rp /home/user /media/...
user avatar
0 votes
1 answer
129 views

How to copy files from a certain range into another directory from terminal?

I want to copy files 50,000 to 100,000 into a separate directory and I'm not sure how to go about doing this. For more context, I want to create a smaller dataset of images (50,000) from a larger ...
user avatar
  • 101
1 vote
2 answers
392 views

How to replace cp command with wget?

I am very newbie to linux and its commands. What I want is use cp command instead of wget to request from browser. Because I'm using docker and the mongo site filtered our country's IP. I have ...
user avatar
6 votes
1 answer
4k views

How can I copy a directory without copying a specific file or subdirectory in terminal?

I have a directory main_dir which contains lots of files and 3 subdirectories (dir1 and dir2 and dir3). I want to copy it to another location without copying dir2 in one command. I searched the cp ...
user avatar
  • 75
1 vote
1 answer
3k views

how to include wildcard characters in cp command

I want to use cp command in a script where the path structure has variable folder name. For example: folder structure: Workspace/unzipped_workspace/artifactory/my_folder123243/files Here ...
user avatar
  • 113
3 votes
1 answer
694 views

Copying or rsyncing only files from subdirectories

I have a folder which is named Music. This folder contains the three subfolders Jazz, Rock and Folk. Now each of these three subfolders contains various .mp3 files. Now I want to copy the .mp3 files ...
user avatar
  • 31
0 votes
2 answers
846 views

cp -r not copying all files from networked drive

I have an unusual problem, which is possibly down to me being a novice command line user, but also applies to using the GUI. The situation is that I have a networked drive mounted at /media/drive/dir ...
user avatar
  • 111
4 votes
2 answers
793 views

Copying directories in linux only if it contains the specified file

I need to make a copy of all the folders under /parent (into a new location) but only if it has 123.dat - in which case I need to copy the folder too, but none of the other files it contains. So that ...
user avatar
  • 143

1
2 3 4 5