cp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. .TH CP 1
  2. .SH NAME
  3. cp, fcp, mv \- copy, move files
  4. .SH SYNOPSIS
  5. .B cp
  6. [
  7. .B -gux
  8. ]
  9. .I file1 file2
  10. .br
  11. .B cp
  12. [
  13. .B -gux
  14. ]
  15. .I file ... directory
  16. .PP
  17. .B fcp
  18. [
  19. .B -gux
  20. ]
  21. .I file1 file2
  22. .br
  23. .B fcp
  24. [
  25. .B -gux
  26. ]
  27. .I file ... directory
  28. .PP
  29. .B mv
  30. .I file1 file2
  31. .br
  32. .B mv
  33. .I file ... directory
  34. .SH DESCRIPTION
  35. In the first form
  36. .I file1
  37. is any name and
  38. .I file2
  39. is any name except an existing directory.
  40. In the second form the commands
  41. copy or move one or more
  42. .I files
  43. into a
  44. .I directory
  45. under their original file names, as if by a sequence of
  46. commands in the first form.
  47. Thus
  48. .L "cp f1 f2 dir
  49. is equivalent to
  50. .LR "cp f1 dir/f1; cp f2 dir/f2" .
  51. .PP
  52. .I Cp
  53. copies the contents of plain
  54. .I file1
  55. to
  56. .IR file2 .
  57. The mode and owner of
  58. .I file2
  59. are preserved if it already
  60. exists; the mode of
  61. .I file1
  62. is used otherwise.
  63. The
  64. .B -x
  65. option sets the mode and modified time of
  66. .I file2
  67. from
  68. .IR file1 ;
  69. .B -g
  70. sets the group id; and
  71. .B -u
  72. sets the group id and user id (which is usually only possible if the file server is in an administrative mode).
  73. .PP
  74. .I Fcp
  75. behaves like
  76. .I cp
  77. but transfers multiple blocks in parallel while copying;
  78. it is noticeably faster than
  79. .I cp
  80. when the files involved are stored on servers connected over long-distance lines.
  81. It is only appropriate to use
  82. .I fcp
  83. with file servers that respect the
  84. .I offset
  85. in
  86. .IR read (5)
  87. and
  88. .I write
  89. messages.
  90. This includes the disk-based file systems and ramfs
  91. but excludes most device file systems.
  92. .PP
  93. .I Mv
  94. moves
  95. .I file1
  96. to
  97. .IR file2 .
  98. If the files are in the same directory,
  99. .I file1
  100. is just renamed;
  101. otherwise
  102. .I mv
  103. behaves like
  104. .I cp
  105. .B -x
  106. followed by
  107. .B rm
  108. .IR file1 .
  109. .I Mv
  110. will rename directories,
  111. but it refuses to move a directory into another directory.
  112. .SH SOURCE
  113. .B /sys/src/cmd/cp.c
  114. .br
  115. .B /sys/src/cmd/fcp.c
  116. .br
  117. .B /sys/src/cmd/mv.c
  118. .SH "SEE ALSO"
  119. .IR cat (1),
  120. .IR stat (2),
  121. .IR read (5)
  122. .SH DIAGNOSTICS
  123. .IR Cp ,
  124. .IR fcp ,
  125. and
  126. .I mv
  127. refuse to copy or move files onto themselves.