Questions tagged [copy]

To copy is to create a duplicate of an object without destroying the original. Commonly seen in text editors that will let you copy some text and paste it somewhere else.

In computing, copy is related both to the command by which a duplicate of a specified entity is made, both in terms of its definition and content, as well as the resulting duplicate itself.

In terms of abstracted use, 'copy' such as when performing a cut-copy-paste operation via a graphical user interface, is an interface metaphor based on the physical procedure used in manuscript editing to create a page layout.

11278 questions
309
votes
10 answers

Copy files from one directory into an existing directory

In bash I need to do this: take all files in a directory copy them into an existing directory How do I do this? I tried cp -r t1 t2 (both t1 and t2 are existing directories, t1 has files in it) but it created a directory called t1 inside t2, I…
David Chang
  • 3,091
  • 2
  • 15
  • 3
303
votes
17 answers

How can I create a copy of an Oracle table without copying the data?

I know the statement: create table xyz_new as select * from xyz; Which copies the structure and the data, but what if I just want the structure?
Andrew
  • 12,991
  • 15
  • 55
  • 85
291
votes
7 answers

What is the difference between `sorted(list)` vs `list.sort()`?

list.sort() sorts the list and replaces the original list, whereas sorted(list) returns a sorted copy of the list, without changing the original list. When is one preferred over the other? Which is more efficient? By how much? Can a list be…
alvas
  • 115,346
  • 109
  • 446
  • 738
286
votes
12 answers

What is the difference between shallow copy, deepcopy and normal assignment operation?

import copy a = "deepak" b = 1, 2, 3, 4 c = [1, 2, 3, 4] d = {1: 10, 2: 20, 3: 30} a1 = copy.copy(a) b1 = copy.copy(b) c1 = copy.copy(c) d1 = copy.copy(d) print("immutable - id(a)==id(a1)", id(a) == id(a1)) print("immutable - id(b)==id(b1)",…
deeshank
  • 4,286
  • 4
  • 26
  • 32
277
votes
18 answers

Using scp to copy a file to Amazon EC2 instance?

I am trying to use my Mac Terminal to scp a file from Downloads (phpMyAdmin I downloaded online) to my Amazon EC2 instance. The command I used was: scp -i myAmazonKey.pem phpMyAdmin-3.4.5-all-languages.tar.gz …
HoKy22
  • 4,057
  • 8
  • 33
  • 54
268
votes
23 answers

How to copy files from 'assets' folder to sdcard?

I have a few files in the assets folder. I need to copy all of them to a folder say /sdcard/folder. I want to do this from within a thread. How do I do it?
Rohith Nandakumar
  • 11,367
  • 11
  • 50
  • 60
265
votes
10 answers

How to deep copy a list?

After E0_copy = list(E0), I guess E0_copy is a deep copy of E0 since id(E0) is not equal to id(E0_copy). Then I modify E0_copy in the loop, but why is E0 not the same after? E0 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] for k in range(3): E0_copy =…
Shen
  • 2,911
  • 3
  • 15
  • 10
261
votes
5 answers

Git: copy all files in a directory from another branch

How do I copy all files in a directory from another branch? I can list all of the files in that directory by doing git ls-tree master:dirname I can then copy all of the files individually by doing git checkout master -- dirname/filename However,…
alexenko
  • 2,913
  • 2
  • 18
  • 10
259
votes
7 answers

How to copy text to clipboard/pasteboard with Swift

I'm looking for a clean example of how to copy text to iOS clipboard that can then be used/pasted in other apps. The benefit of this function is that the text can be copied quickly, without the standard text highlighting functions of the traditional…
Garry Law
  • 2,936
  • 2
  • 16
  • 14
257
votes
26 answers

Eclipse copy/paste entire line keyboard shortcut

Anyone know the keyboard shortcut to copy/paste a line into a new line in Eclipse, without having to highlight the entire line? ctrl-alt-down turns my whole screen upside down (I'm on windows). Interestingly, that's what's specified in the…
Prabhu
  • 12,995
  • 33
  • 127
  • 210
247
votes
16 answers

MySQL: Cloning a MySQL database on the same MySql instance

I would like to write a script which copies my current database sitedb1 to sitedb2 on the same mysql database instance. I know I can dump the sitedb1 to a sql script: mysqldump -u root -p sitedb1 >~/db_name.sql and then import it to sitedb2. Is…
uclajatt
  • 4,003
  • 4
  • 21
  • 11
244
votes
7 answers

Git copy file preserving history

I have a somewhat confusing question in Git. Lets say, I have a file dir1/A.txt committed and git preserves a history of commits Now I need to copy the file into dir2/A.txt (not move, but copy). I know that there is a git mv command but I need…
Mark Bramnik
  • 39,963
  • 4
  • 57
  • 97
230
votes
7 answers

How to export all data from table to an insertable sql format?

I have a Table (call it A_table) in a database (call it A_db) in Microsoft SQL Server Management Studio, and there are 10 rows. I have another database (call it B_db), and it has a Table (call it B_table), which has the same column settings as…
victorio
  • 6,224
  • 24
  • 77
  • 113
229
votes
13 answers

How do I copy a hash in Ruby?

I'll admit that I'm a bit of a ruby newbie (writing rake scripts, now). In most languages, copy constructors are easy to find. Half an hour of searching didn't find it in ruby. I want to create a copy of the hash so that I can modify it without…
Precipitous
  • 5,253
  • 4
  • 28
  • 34
226
votes
15 answers

How to clone or copy a list in kotlin

How to copy list in Kotlin? I'm using val selectedSeries = mutableListOf() selectedSeries.addAll(series) Is there a easier way?
Adolf Dsilva
  • 13,092
  • 8
  • 34
  • 45