Questions relating to the Linux 'cp' command.
Questions tagged [cp]
224 questions
10
votes
4 answers
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.
/tmp $ cp -f -R --verbose /tmp/a /tmp/b
`/tmp/a' ->…
2
votes
1 answer
cp -Rdfp $source/* $dest/ wont copy .htaccess
This command wont copy .htaccess files:
cp -Rdfp $source/* $dest/
Thanks

SexyMF
- 195
2
votes
1 answer
Why can I not copy file with cp -rf mydir/* .../mydir/.?
When I try to copy cp -rf mydir/* .../mydir/. I get next error:
cp: cannot stat 'mydir/*': No such file or directory
But there are files in this directory.
Please help me to find out reason of it.

Dmitro
- 133
1
vote
1 answer
Copy one file to other of same name
I have 2 folders with same name (pepe pepe). i want to copy the files of pepe to other one without lossing the files of destination .
how i can do it ?
copying new files from pepe folder to other folder pepe without lossing any file
thanks

Anique Awan
- 33
1
vote
2 answers
cp not copying files?
cp -v /var/www /var/www/dev
cp -vR /var/www/admin /var/www/dev
cp -vR /var/www/cron /var/www/dev
cp -vR /var/www/css /var/www/dev
cp -vR /var/www/files /var/www/dev
cp -vR /var/www/images /var/www/dev
cp -vR /var/www/js /var/www/dev
cp -vR…

TheMeisterSE
- 129
1
vote
1 answer
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.jar
First command removes the old paper_RPG.jar, and…

Mithrandir
- 79
1
vote
1 answer
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 does not stop processing. Any help would be much…

Waleed Naveed
- 121
0
votes
1 answer
Copy and Rename at the same time - No such file or directory
shuf -zn1 -e *.jpg | xargs -0 cp -vt /home/myspace/
result i.e. Image00005.jpg
BUT, I want to rename the file at the same time
i.e. Image00005.jpg to Image.jpg
Tried:
shuf -zn1 -e *.jpg | xargs -0 cp -vt /home/myspace/image.jpg
cp: failed to…

Confluentes Info
- 107
0
votes
1 answer
cp -p command in ubuntu
set series = usno
if ( ! -e ut1.${series} ) \cp -p ~/gg/tables/ut1.${series} .
I'm trying to grasp a script. I need to know that what cp -p command works in this script?

deepblue_86
- 1,194
0
votes
1 answer
How to do ant style file filtering when copying files
With Ant you can use a filter like:
**/target/*.war
That means all the paths that have target in them as the last directory.
This will match
a/b/target/X.war
a/target/Y.war
a/b/c/target/Z.war
I would like to be able to copy in ubuntu with this…

Michael Wiles
- 437
0
votes
2 answers
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*/

brownser
- 161
0
votes
1 answer
simple question cp (command)
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 want to copy the "perfect" file to "fis2" [which is…

nownoob
- 1
0
votes
2 answers
Copy one file to different, differently named folders
I have a need to copy one file from /a/b/ folder to /a/c/, a/d/, a/e/
Besides using
cp file.name /a/c
cp file.name /a/d
cp file.name /a/e
in the terminal, is there a way to use one line? I have read and seen that thera are ways, but I think my…

Niko
- 51
0
votes
1 answer
Cp does not copy file
This does not copy the file.
I am owner of both directories.
And there are no messages?
cd /home/andy/.mozilla/seamonkey/4e39n1np.default/
cp -f bookmarks.html /home/andy/.mozilla/firefox/mltw8z53.default-1516629000620/
File exists. File can't be…

fixit7
- 3,127
-3
votes
1 answer
What is the use of cp -i command?
Everywhere I read the following description.
-i, --interactive :::::::Before overwriting an existing file, prompt the user for
confirmation. If this option is not specified, cp will
silently overwrite files.
but I am not able to understand…

xscorp7
- 127