cp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. .TH CP 1
  2. .SH NAME
  3. cp, 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 mv
  18. .I file1 file2
  19. .br
  20. .B mv
  21. .I file ... directory
  22. .SH DESCRIPTION
  23. In the first form
  24. .I file1
  25. is any name and
  26. .I file2
  27. is any name except an existing directory.
  28. In the second form the commands
  29. copy or move one or more
  30. .I files
  31. into a
  32. .I directory
  33. under their original file names, as if by a sequence of
  34. commands in the first form.
  35. Thus
  36. .L "cp f1 f2 dir
  37. is equivalent to
  38. .LR "cp f1 dir/f1; cp f2 dir/f2" .
  39. .PP
  40. .I Cp
  41. copies the contents of plain
  42. .I file1
  43. to
  44. .IR file2 .
  45. The mode and owner of
  46. .I file2
  47. are preserved if it already
  48. exists; the mode of
  49. .I file1
  50. is used otherwise.
  51. The
  52. .B -x
  53. option sets the mode and modified time of
  54. .I file2
  55. from
  56. .IR file1 ;
  57. .B -g
  58. sets the group id; and
  59. .B -u
  60. sets the group id and user id (which is usually only possible if the file server is in an administrative mode).
  61. .PP
  62. .I Mv
  63. moves
  64. .I file1
  65. to
  66. .IR file2 .
  67. If the files are in the same directory,
  68. .I file1
  69. is just renamed;
  70. otherwise
  71. .I mv
  72. behaves like
  73. .I cp
  74. .B -x
  75. followed by
  76. .B rm
  77. .IR file1 .
  78. .I Mv
  79. will rename directories,
  80. but it refuses to move a directory into another directory.
  81. .SH SOURCE
  82. .B /sys/src/cmd/cp.c
  83. .br
  84. .B /sys/src/cmd/mv.c
  85. .SH "SEE ALSO"
  86. .IR cat (1),
  87. .IR stat (2)
  88. .SH DIAGNOSTICS
  89. .I Cp
  90. and
  91. .I mv
  92. refuse to copy or move files onto themselves.