Jump to content

Copy (command)

From Alfawiki
copy
Company typeCommand line utility
IndustryComputing / Software
ProductsFile copying utility

copy is a shell command utilized for duplicating files. Various versions provide functionalities including:

  • Merging several files into a single file
  • Transferring multiple source files into an existing directory
  • Differentiating between text and binary data; text mode halts at EOF, while binary mode copies the full file
  • In DOS environments, enabling copying to or from devices, for example, copy path con sends file content to the console, and copy con path creates a file using console input

Implementations

This command is incorporated in a wide range of operating systems such as RT-11, OS/8, RSX-11, ISIS-II, iRMX 86, TOPS-10, TOPS-20, OpenVMS, MetaComCo TRIPOS, HDOS, Z80-RIO, OS-9, DOS, FlexOS, 4690 OS, PC-MOS, Hewlett-Packard’s MPE/iX, OS/2, various versions of Windows, ROM-DOS, ReactOS, SymbOS, DexOS, and 86-DOS.

For IBM PC DOS/MS-DOS systems, this command has been present since the initial release. Alternative names are used in other environments: in Unix-like systems, it appears as cp; within CP/M systems, it is known as PIP; and OpenVOS uses copy_file.

DOS

In DOS, the copy command replicates an existing file designated by fromfile to a target named tofile.

copy fromfile tofile

It supports copying files to hardware devices, for instance sending a document to the printer on lpt1:

copy letter.txt lpt1

The command can also direct output to the console, functioning similarly to the DOS type command:

copy letter.txt con

Concatenation of several files into one is possible, comparable to the Unix cat utility:

copy page1.txt+page2.txt book.txt

Copying across different drives is supported as well.

When operating in text mode, copying stops upon encountering EOF markers:

copy /a doc1.txt + doc2.txt doc3.txt
copy /a *.txt doc3.txt

Binary mode ensures that entire files are copied without regard to EOF characters:

copy /b image1.jpg + image2.jpg image3.jpg

See also

  • XCOPY

Further reading

  • Wolverton, Van. MS-DOS Commands: Microsoft Quick Reference, 4th Revised edition, 1990, Microsoft Press.
  • Ivens, Kathy; Proffit, Brian. OS/2 Inside & Out, 1993, Osborne McGraw-Hill.
  • Frisch, Æleen. Windows 2000 Commands Pocket Reference, 2001, O'Reilly Media.

External links