Questions tagged [cp]

cp is a UNIX command used to copy a file

Description

cp copies SOURCE to the destination DEST, or multiple SOURCE(s) to directory DIRECTORY.

Syntax

cp [OPTION]... [-T] SOURCE DEST

cp [OPTION]... SOURCE... DIRECTORY

cp [OPTION]... -t DIRECTORY SOURCE...

Related commands

824 questions
-1
votes
1 answer

Restore file in ubuntu

Is there anyway to restore replaced file in Ubuntu? The file was replaced using cp command. I tried finding answer but couldn't find anyone. Please help
phenomenal
  • 65
  • 7
-1
votes
1 answer

Intro to Linux cli; output redirection

Why does cp a b result in error when cp a b > a results in no error when neither a nor b file exists. From my understanding cp a b gives error because neither file exists, makes sense and cp a b >a seems to create both files and copy blank from b…
user3238382
  • 31
  • 1
  • 5
-1
votes
2 answers

how to append the data from file x to file y using cp command in linux?

I have file x and file y and I want to append all the contents of x into y without overwriting the file . cp -r /source/y /destination/x I am searching different options of copy command for this but I am not getting the exact way of how to…
govind saraf
  • 1
  • 1
  • 2
-1
votes
1 answer

Able to remove a file being the other user

I had copied a file from one directory to my home directory. Initially, it had permissions and ownerships as (640) and (root:root). I was still able to delete that file. Though, it asked for permission. Any Reasons, as to why this…
-1
votes
1 answer

How to format cp command or ditto in terminal MAC OS X to copy source to multiple destinations

How to format cp command or ditto in terminal to copy source to multiple destinations? I am completely unexperienced in using terminal but have heard that is copies faster and I have large batched to send to multiple USB flash drives all titled NO…
-1
votes
1 answer

When copying folders and entire subtrees what is the difference between cp and rsync

Upon my initial looking both cp and rsync will copy an entire directory structure. That being said, what is the purpose for each and which is better? cp -R $source $destination vs rsync -auq $source $destination I was trying to look into and…
Fallenreaper
  • 10,222
  • 12
  • 66
  • 129
-1
votes
1 answer

c++ copying directory into an another directory (linux cp command)

I'm trying to implement cp -r command so that when user types in cp -r dir dir1, dir gets copied and pasted inside dir1. Below is what i have so far and it does copy the files and directories inside the directory, but it doesn't copy directory…
james jung
  • 21
  • 1
  • 4
-1
votes
3 answers

How do I correct this UNIX command for copying files into a directory?

I have the following command that does not work while read line; do ls $line | head -10 | cp xargs dest_folder; done < my_file.txt The objective is that I have a file named my_file.txt that contains the name of a folder on every line. I want to…
London guy
  • 27,522
  • 44
  • 121
  • 179
-1
votes
3 answers

Linux cp with variables

I'd like to copy a file that is specified by a variable in a Linux bash file. This is how it does not work: molecules = (1butene E2butene) for molecule in ${molecules[*]} do ### some stuff (works) formchk $molecule.chk $molecule.fchk ###…
user7408924
  • 97
  • 2
  • 9
-1
votes
2 answers

Evaluate Linux file copy command in c

I have the following program below which copies the whole text file of the one to another where you input the name of the source file and the destination file. I need to modify my program to evaluate the Linux cp command. My subcopy command will…
user7038047
-1
votes
1 answer

Copying directories to a server and deleting all unnecessary files

When copying websites to my server, I noticed that files I had deleted in my local environment were still present on the server after the rsync or scp. I did some research and found this question which thoroughly explains my problem; though…
Palmer
  • 173
  • 9
-1
votes
2 answers

How to copy a file in one directory and move it to the other?

So, I am currently in my lab6 folder. In that folder, I have a makefile that is very similar to the one I need in lab7. So, I just want to copy that makefile in lab6 and move it to lab7. My current directory is…
CodeFreak
  • 90
  • 1
  • 2
  • 15
-1
votes
1 answer

cp -R No such file or directory

Why is this failing (on OS X)? $ cp -R dir1 dir2 ... # List of all the files in dir1 prefixed with "dir2" cp: dir2/g: No such file or directory cp: dir2/h: No such file or directory cp: dir2/i: No such file or directory cp: dir2/j: No such file or…
David Winiecki
  • 4,093
  • 2
  • 37
  • 39
-1
votes
1 answer

How do I copy a file in multiple folders in Ubuntu?

I have directory named "public" in every directory inside Documents. I want to copy file named File.txt in every directory "public". cp -r File.txt Documents/*/public/ doesn't seam to work. What should I do?
Saket Patel
  • 413
  • 3
  • 13
-1
votes
1 answer

Cygwin is telling me a file doesn't exist when it does

I'm trying to copy some files to set up Giza++ in Cygwin with the command cp ~/mosesdecoder/giza-pp/GIZA++-v2/GIZA++ ~/mosesdecoder/giza-pp/GIZA++-v2/snt2cooc.out \~/mosesdecoder/giza-pp/mkcls-v2/mkcls.cpp tools However when I run it, I get the…
user2785277
  • 345
  • 4
  • 19