Questions tagged [cp]
Questions relating to the Linux 'cp' command.
21
questions
1312
votes
8
answers
3.9m
views
How can I copy the contents of a folder to another folder in a different directory using terminal?
I am trying to copy the contents of a folder to another folder in a different directory using terminal.
Would somebody be able to provide me an example of the command line syntax required to achieve ...
15
votes
5
answers
86k
views
Recursively copy files from one directory to another
I have all my music in a folder /media/kalenpw/MyBook/Music/ABunchOfOtherFoldersWithFilesInside. I want to copy all of the mp3s to /media/kalenpw/HDD/Music so I used:
cp -R /media/kalenpw/MyBook/...
99
votes
10
answers
164k
views
How to copy a file to multiple folders using the command line?
I have tried to copy a file test.txt to multiple directories with one command:
cp ~/test.txt ~/folder1 ~/folder2
But I didn't succeed. Is there a way to do that in one command so I can copy a file ...
76
votes
5
answers
216k
views
cp command to exclude certain files from being copied
Is there a way to use the cp command to copy a directory and exclude certain files/sub-directories within it?
3
votes
1
answer
5k
views
How can I recursively copy files by file extension? [duplicate]
I would like to copy all files with a certain extension that are in sub directories to a different folder. I don't want to maintain the directory structure, I just want to copy all files found to a ...
112
votes
3
answers
170k
views
Copy a file and keep the same timestamp of the original file
I need to a copy file and after that I need to change the timestamp attributes as the original file. How can I do it with the terminal or any other way?
23
votes
2
answers
60k
views
Is there any way to create backup copy of a file, without type its name twice? [duplicate]
Often when I'm editing some system file first I create a backup copy. For example:
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
Is there any simple 'shortcut' such as:
sudo cp /etc/ssh/...
41
votes
5
answers
576k
views
cp - cannot create regular file : permission denied
I want copy to /lib/udev but gives error
cp -f /tmp/ok_pcscd_hotplug.sh /lib/udev
cp:cannot create regular file /lib/udev/ok_pcscd_hotplug : Permission denied
I am root , but I can't understand . ...
24
votes
2
answers
55k
views
force cp to copy on dangling symlinks
Is there any way to force cp (Bash 4.2.5, Ubuntu 12.04) to copy onto a dangling symlink?
cp a-file path/to/danling/symlink/a-file
cp: not writing through dangling symlink `path/to/danling/symlink/a-...
21
votes
2
answers
42k
views
What's the difference between ` cp ` and ` rsync `? [closed]
They seem similar to me. I want to know how to use them. What's the difference in structure?
2
votes
2
answers
381
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 ...
2
votes
3
answers
2k
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....
1
vote
3
answers
4k
views
Why does cp not copy a specified folder
let's say that I have a following file structure:
~/DIR1
-fileA
-DIR2
--fileB
Then, being in ~, I run this script:
cp DIR1 NEWDIR2
And just an error happens:
cp: omitting directory ‘DIR1’
I ...
18
votes
2
answers
108k
views
Ubuntu copying file problem (cannot stat file)
I've faced a problem when copying a file with the commands,
cp ~/Downloads/sample.pdf ~/Desktop/
But the terminal gives me a message, cp: cannot stat 'sample.pdf': No such file or directory.
10
votes
4
answers
8k
views
How to copy into with cp if destination folder already exists?
Example...
This is what I want.
/tmp $ cp -f -R --verbose /tmp/a /tmp/b
`/tmp/a' -> `/tmp/b'
`/tmp/a/file2' -> `/tmp/b/file2'
`/tmp/a/file1' -> `/tmp/b/file1'
This is what I do not want.
/...
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 ...
4
votes
2
answers
6k
views
What happens when you force quit a `mv` directory operation between two disks?
Another way to word the question is...
What happens when you mv a directory between two disks?
Does it move one file after the other, or does it copy all files to destination, then then delete ...
4
votes
1
answer
26k
views
getting razercfg to work using systemd - systemctl: command not found
My goal is to change my mouse DPI. So any less frustrating solution is also welcome.
I'm trying to get this program to work and i'm following it's README file:
http://bues.ch/cms/hacking/razercfg....
1
vote
3
answers
44k
views
Copy file to External Hard Disk
My UBUNTU (desktop part) does not boot completely because of low disk space;
I logged in to terminal using my username and password, try to copy some file from /home/UserName/Desktop to my external ...
0
votes
1
answer
102
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
2
answers
1k
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 ...