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

How can I use "cp --sparse=always" in Mac?

I just follow this page to build custom oracle linux machine image. I want to use cp cp --sparse=always like Converting the VM Disk to a Machine Image of that page in my Mac. But, my Mac cannot recognize this option. How can I follow this step in my…
-1
votes
2 answers

What are the linux commands to create a new folder & copy all the files & folders present in '/var/www/' into it to take backup of all code files?

Let me assure you that the operations I'm going to perform is on my live production server, so there is no scope for any error. The server as well as my local machine are using Linux operating system only. I'm able to login through the terminal on…
PHPLover
  • 1
  • 51
  • 158
  • 311
-1
votes
2 answers

bash find change name file for directory name 2 levels up

Hello and thanks for reading! I have list like that: user@laptop:~/lol$ find ./ \( -iname 'latest*' \) -type f -printf…
Tomeu Cabot
  • 433
  • 2
  • 8
-1
votes
2 answers

Copying one file to another(Unix/C)?

I have written the following code to copy one file to another. Although the code works, the code still prints both error messages. Why is this ? I am a complete beginner to Unix and C programming(although I have worked with C++ before), so any help…
Jenna Maiz
  • 792
  • 4
  • 17
  • 38
-1
votes
2 answers

Explain me 2 lines of this shell script

What does this mean? if [ -f $2/$1 ] and this line: cp $1 $2/$1 Does $2/$1 represent a file, because it's associated with -f? #!/bin/bash if test $# -ne 2 then echo "Numbers of argument invalid" else if [ -f $2/$1 ] then echo "file…
Alba
  • 5
  • 4
-1
votes
2 answers

-a option in `cp` command -- what does it do?

What does the -a option do in the cp command? I thought that the -a does not preserve the structure of directories. But, I have never found a case where the structure of directories has been destroyed by the -a option. is there such a case…
makansij
  • 9,303
  • 37
  • 105
  • 183
-1
votes
3 answers

linux copy and paste two last increment filename

I want to copy and paste file in linux, but i want to keep only the two last increment of filename, for example my code generate a list of file : aa001 bb001 aa002 bb002 aa003 bb003 aa004 bb004 So I want to keep the two last increment ( *003…
daday001
  • 91
  • 1
  • 9
-1
votes
1 answer

How do I copy a file from my desktop, to another directory not on my desktop?

In my Desktop directory, I have a file called "ex12.txt" I want to copy it and move it to another directory named "temp" in another location. I've tried this: Jahvons-MacBook-Air:desktop jahvonashmeade$ cp ex12.txt temp/ Then I get this cp:…
-1
votes
4 answers

Bash Shell Script to copy files from source to destination

I have a question related to my bash shell script. Basically, I need to develop a script that copies certain files from one directory to another. Sounds easy, however, its quite a challenge for me and I hope some of you might help me. So script…
MrQuartz
  • 21
  • 1
  • 1
  • 4
-1
votes
1 answer

What is the fastest method to copy directory in linux?

Linux is offering much less copying speed compared to windows.To copy 1GB data in linux it takes much more time compared to windows.So please suggest me to copy directory as effective as windows.I tried using cp,rsync and also changed the file…
Kernel
  • 29
  • 6
-1
votes
4 answers

How to delete the contents of all the files in a directory

Under /tmp/REPORTS I have a hundred files. What I want to do is erase the contents of each file in /tmp/REPORTS (not delete them). So I tried the following, but I get this error: cp /dev/null /tmp/REPORTS/* cp: Target /tmp/REPORTS/….. must be a…
maihabunash
  • 1,632
  • 9
  • 34
  • 60
-1
votes
1 answer

UNIX/ copy directory to new directory

I need to copy a directory and its content to a NEW directory. Using: cp -r dir1/dir2 dir1/dir3 where dir3 is going to be created anew, it just copies the file(s) I have within dir2... It's like it copies dir2 naming it dir3. Is there any way to…
Da Real Pope
  • 1
  • 1
  • 1
-1
votes
1 answer

Copying files via system call fails on PHP

I try to copy some files from one directory on server to another, but it does not work. Here is my code: system('cp /var/www/site1/images/' . $row['imageUrl']. ' /var/www/site2/content/upload/content/item/mid/' . $row['imageUrl']);
nowiko
  • 2,507
  • 6
  • 38
  • 82
-1
votes
1 answer

passing a grep list as an argument to cp

lets say I want to copy a list of files to another directory -rw-rw---- Sep 1 11:06 File1.txt -rw-rw---- Sep 1 11:06 File101.txt -rw-rw---- Sep 3 11:06 File2.txt -rw-rw---- Sep 4 11:06 File303.txt I would like to grep all…
Rubenex
  • 469
  • 2
  • 8
  • 23
-1
votes
1 answer

Input/Output error when copying files to a mount inlinux

I am having a linux mount on my jenkins build server. After a job in jenkins succeeds, a script is being called which copies the files from workspace to different directories in the mount. Each time I mount the copy operation succeeds but after few…
Jninja
  • 149
  • 1
  • 3
  • 13