Questions tagged [cp]
Questions relating to the Linux 'cp' command.
221
questions
0
votes
1
answer
55
views
Having trouble moving symlinks from backup to boot partition
The context
I have a dual-boot Ubuntu (Jammy Jellfish)/Windows laptop (Dell XPS 9550). My /boot partition was too small to support an update, so I used GParted to attempt to resize it. However, I ...
0
votes
1
answer
73
views
How to fix this error in cp?
#!/bin/bash
SrcDir=$1
DstDir=$2
#If DstDir is not exist, this creats it
if ! [ -a $DstDir ]; then
mkdir $DstDir
fi
#Formats
Vformat=(mp4 avi 3gp mpeg mkv wmv mov)
Iformat=(jpg jpeg png)
Year(){...
0
votes
1
answer
57
views
How to best copy large folders?
I want to copy 1 TB of data from 1 HDD to another via Terminal.
What is the best approach to this?
So far, i've used the following, but I've no idea, whether it actually makes progress, or if it just ...
0
votes
2
answers
60
views
How can we copy a file to all subdirectories using cp and wildcard
Let's say I have 10 subdirectories in a main-directory named d1, d2, d3, ..., d10. How can I copy a file into all these subdirectories using cp?
I'm looking for something like
cp ./my_file.txt ./d*/
1
vote
1
answer
297
views
Anyway to undo overwriting file by mv or recover replaced file?
I accidentally mv a new file to an existing file and overwrote it. Is there anyway to undo mv or recover the replaced file?
1
vote
1
answer
147
views
Having trouble copying conda environment folder containing same word (different case) files with symbolic links in terminfo subdirectory
I am using WSL1.
I am trying to save a copy of my ~./miniconda/envs folder to the desktop using cp.
I keep getting errors like cp: cannot create regular file './envs/py_env/share/terminfo/h/hp2621a':...
-4
votes
1
answer
135
views
Copy some files from source directory A to directory B and some files to Directory C with non sequential order
I am looking for a script to copy files from a source directory to two destination directories with non sequential order.
For instance I want to copy some files from source directory A/ to destination ...
0
votes
2
answers
31
views
Copying a downloaded file into my current terminal folder
I am compiling WRF on my HP Desktop.
I'm in Ubuntu terminal and trying to use the cp command to copy from my D Drive, but it just won't work.
Using cp D:\MyWRF/file.tar .
All I get is cannot stat, ...
0
votes
0
answers
204
views
How to move file from one partition to the other
I have a file in ~/.config/gtk-3.0 I wanted to back up as I make changes to it. I cannot paste it into my /Shared Drive/ - rather a partition - formatted as FAT32 and the drive is mounted on boot. I ...
0
votes
1
answer
657
views
Copying file with the same name from different directories to the directory before
I have a set of 120 files, all with the same name,contig.fa which are located in the hierarchy of
Main Directory 1
Subdirectory 1
file.fa
Main Directory 2
Subdirectory 2
file.fa
I ...
7
votes
1
answer
1k
views
Why does "cp" complain about identical files when chaining with "find"?
I have a find command as below that lists the matching files:
$ find . -type f -name "*.txt"
./level2/file2.txt
./level2/level3/file3.txt
./level2/level3/level4/file4.txt
./level2/level3/...
0
votes
0
answers
320
views
cannot paste external files into a ntfs file system in Ubuntu 20.04.4
on Ubuntu 20.04.4 LTS I have an NTFS data partition. This is a dual boot system with Windows 10. The option "paste" is grayed out when I try to copy-paste into the NTFS partition any file ...
0
votes
1
answer
22
views
Link directory to another directory to ccopy files
I have a folder:
/share/public
I am working in the folder:
/home/john/workingfolder
It means that currently I am in the "workingfolder".
I would like to send files to /share/public but ...
0
votes
1
answer
60
views
How do I copy a local home dir to an iscsi mounted home directory
I have various Ubuntu images on this machine, each with their own home dir. I am trying to consolidate them on a redundant iscsi NAS. This seems like it should be straight forward. It eventually locks ...
0
votes
0
answers
36
views
Having two different Downloads [duplicate]
I'm trying to move or copy a file Bs_T.txt from Downloads C:\Users\Laptop\Downloads to repository with path /home/p/pand. When I try to find a file called Bs_t.txt with command readlink -f Bs_t.txt I ...
4
votes
2
answers
2k
views
Make multiple copies of one file with different names
How can I create multiple file from one?
Like, I have 1.json, but want to create 2.json + 3.json + 4.json out of it.
Most obvious way is to just cp 1.json 2.json and so on; but does Linux provide some ...
0
votes
0
answers
513
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 "...
0
votes
1
answer
2k
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: ...
1
vote
1
answer
162
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....
0
votes
1
answer
198
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-...
0
votes
2
answers
1k
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 ...
0
votes
1
answer
73
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 ...
0
votes
1
answer
229
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 /...
0
votes
1
answer
1k
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 ...
1
vote
2
answers
968
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 ...
0
votes
2
answers
98
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 ...
0
votes
1
answer
637
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 ...
1
vote
1
answer
254
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 ...
0
votes
2
answers
2k
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 ...
2
votes
2
answers
148
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 ...
0
votes
0
answers
600
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 ...
2
votes
1
answer
138
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 ...
1
vote
0
answers
520
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 ...
0
votes
1
answer
328
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 ...
1
vote
1
answer
119
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 ...
-3
votes
1
answer
132
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)?
8
votes
2
answers
4k
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 ...
2
votes
3
answers
3k
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 ...
0
votes
1
answer
2k
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 ...
1
vote
2
answers
409
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-...
0
votes
1
answer
444
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?
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 ...
0
votes
1
answer
2k
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/...
1
vote
2
answers
379
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 :
...
1
vote
1
answer
167
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....
0
votes
0
answers
2k
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 ...
0
votes
1
answer
3k
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 ...
1
vote
1
answer
26k
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 ...
0
votes
2
answers
77
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 ...
2
votes
3
answers
405
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 ...