-
Notifications
You must be signed in to change notification settings - Fork 1
/
cp.1
262 lines (191 loc) · 10.2 KB
/
cp.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
CP(1) Human68k ITA TOOLBOX User's Manual CP(1)
名称
cp - ファイルやディレクトリをコピーする
形式
cp [ -IRSTVadefhinprsuvx ] [ -m mode ] [ -- ] source dest
cp [ -BCDILPRSTUVadefhinprsuvx ] [ -m mode ] [ -- ]
source ... targetdir
解説
cp はファイルやディレクトリをコピーします.ファイルからデバ
イス,デバイスからファイル,およびデバイスからデバイスへのデー
タ転送も行うことができます.
第1の形式では source を dest にコピーします.第2の形式では
source ... をそれぞれ元のファイル名のままディレクトリ
targetdir の中にコピーします.source ... は左から右に順番に
処理され,-e オプションが指定されていなければ,もし途中でエ
ラーがあっても処理は最後まで続行されます.この 2つの形式は最
後の引数がディレクトリ(またはディレクトリへのシンボリック・
リンク)であるかどうかで区別されます.
‘A:’のようなドライブ名のみの指定は,そのドライブのカレント・
ディレクトリを意味します.
ディレクトリをコピーするには,-r オプションかまたは -R オプ
ションを指定してください.このオプションは,source がディレ
クトリである場合,そのディレクトリはもちろん,それ以下のすべ
てのファイルやディレクトリを再帰的にコピーします.
コピー先の属性は次にように設定されます.
・新規ファイル
・新規ディレクトリ
source から属性もコピーされます.source に属性が無い場
合は,読み書き可,実行不可となります.いずれの場合も -m
オプションによって変更されます.
・既存ファイル
属性は通常は元のまま保存されますが,-p オプションを指定
すると,もし source に属性があれば source から属性もコ
ピーされます.いずれの場合も -m オプションによって変更
されます.
・既存ディレクトリ
属性は元のまま保存されます.-p オプションや -m オプショ
ンは無効です.
コピー先のタイムスタンプは次にように設定されます.
・新規ファイル
・既存ファイル
・新規ディレクトリ
タイムスタンプは通常は更新されますが,-p オプションを指
定すると,もし source にタイムスタンプがあれば source
からタイムスタンプもコピーされます.
・既存ディレクトリ
タイムスタンプは元のまま保存されます.-p オプションは無
効です.
cp は沖版 lndrv によるシンボリック・リンク(以下では単に『シ
ンボリック・リンク』と記します)をサポートしています.-d オ
プションが指定されていなければ,シンボリック・リンクに対する
アクセスは,リンクが参照する実体へのアクセスとなります.その
場合,lndrv がシステムに組み込まれていなければなりません.
コピー元とコピー先が同一のエントリである場合はエラーとなりま
す.
cp には 次のオプションがあります.
-a -dpr と同じです.
-d シンボリック・リンクが参照する実体にアクセスする代
わりにリンク・ファイルそのものにアクセスします.シ
ンボリック・リンクは,そのままシンボリック・リンク
としてコピーされることになります.また,コピー先に
シンボリック・リンクが存在している場合は,そのリン
ク・ファイルが上書きの対象となります.通常これは結
果的にはエラーとなりますが,-f オプションを指定す
れば,コピー先のリンク・ファイルが予め削除され,そ
れに代わってコピーが新規作成されることになります.
このオプションは,cp の 2つの形式の判別(最後
の引数がディレクトリであるかどうかの判定)には影響
しません.
-e 何らかのエラーが起こったとき,処理を続行せずに即終
了します.
-f コピー先に同名のファイルが存在していれば,それを予
め強制的に削除してコピー先を新規に作成します.また,
ボリューム・ラベルのコピー先のディレクトリ内にボ
リューム・ラベルが存在していれば,それも予め強制的
に削除します.
削除は -u オプションや -i オプションの処理後に行わ
れます.
-i コピー先に同名のファイルが存在している場合,上書き
するかどうかを問い合わせます.問い合わせに対して
‘y’で始まる行を入力するとコピーが行われ,それ以
外の入力ではコピーをとりやめて次のファイルやディレ
クトリの処理に進みます.
問い合わせに対して‘y’で始まる行を入力しても,
上書きが必ず成功するとは限りません.コピー先に存在
するファイルの属性によっては結果的にエラーとなる場
合があります.そのような場合も強制的にコピーしたい
場合には -f オプションを併用してください.この ITA
TOOLBOX の cp では,-f オプション と -i オプション
は互いに打ち消し合うものではありません.
-I ファイルやディレクトリ毎に問い合わせを行います.こ
のオプションは -i オプションを覆います.
-n -v オプションと同じ報告をし,実際にはコピーしませ
ん.-f オプションによる削除も行いません.
-p ファイルや新規作成されるディレクトリに対して(もし
あれば)属性とタイムスタンプもコピーします.-m オ
プションによる修正はその属性に対して働くことになり
ます.
-r ディレクトリを再帰的にコピーします.
-R ディレクトリ毎にコピーするかどうかを問い合わせます.
問い合わせに対して‘y’で始まる行を入力すると -r
オプション指定時と同様にコピーされ,それ以外の入力
ではコピーをとりやめて次のファイルやディレクトリの
処理に進みます.このオプションは -r オプションを覆
います.
-s ファイル(ディレクトリは除く)をコピーする代わりに,
そのファイルを参照するシンボリック・リンクを作成し
ます.ただし,コピー元が相対パスで示される場合には,
コピー先は‘.’(カレント・ディレクトリ)でなけれ
ばなりません.
-u ファイル(ディレクトリを除く)をコピーするとき,コ
ピー先にファイルが存在していて,それがコピーしよう
とするファイルよりも新しければ,コピーしません.そ
の場合には問い合わせも行われません.
-v ファイルやデバイスをコピーする直前に,そのパス名と
コピー先を標準出力に出力します.ディレクトリを作成
したときには,その直後に報告します.
-x ディレクトリを再帰的にコピーするとき,コピーを始め
る最上位のディレクトリと同じドライブにあるファイル
やディレクトリのみをコピーし,違うドライブにあるファ
イルやディレクトリはコピーしません.その場合には問
い合わせも行われません.
-m mode コピー先のファイルや新たに作成されるディレクトリに
本来与えられる属性を mode に従って変更します.
この機能は ITA TOOLBOX の chmod(1) に準じます.
mode の書式は ITA TOOLBOX の chmod(1) と同じです.
-m オプションを複数指定した場合には,最後の指定の
みが有効となります.
-P たとえば cp -P a/b/c /d/e/f G:/h/i/j targetdir で
は,a/b/c を targetdir/a/b/c に,/d/e/f を
targetdir/d/e/f に,G:/h/i/j を targetdir/h/i/j に
コピーします.targetdir は存在するディレクトリでな
ければなりません(このオプションは第2の形式でのみ
サポートされます).パス targetdir/a/b,
targetdir/d/e,targetdir/h/i は,存在しなければ作
成されます(ただしコピーするファイルが存在していな
ければ,パスの作成は行われません).このパスの作成
処理は,どのオプションの影響も受けません.
-S システム・ファイルをコピーしません.
-V ボリューム・ラベルもコピーします.
-h システム・ファイルをコピーした後にそのFATを調べ,
不連続になっていれば,コピーをやりなおすかどうかを
問い合わせます.システム・ファイルのコピー先がルー
ト・ディレクトリの先頭32エントリ外に作られた場合に
はエラーとします.ディレクトリをコピーする際にはシ
ステム・ファイルを優先します.
-T コピーしたファイルのFATが不連続となった場合,コピー
をやりなおすかどうかを問い合わせます.
-B ファイルやディレクトリを元の名前でコピーする場合に,
コピー先の名前をMS-DOSのディレクトリに納まる長さ(
ピリオドまで8バイト以内,ピリオド以降 3バイト以内)
に切り詰めます.ピリオドを 2個以上含む名前やピリオ
ドで始まる名前のファイルやディレクトリはコピーせず
にエラーとします.
-C ファイルやディレクトリを元の名前でコピーする場合に,
その名前がMS-DOSのディレクトリに納まらない場合,代
わりの名前を問い合わせます.このオプションは -B オ
プションを覆います.
-D ファイルやディレクトリを元の名前でコピーする場合に,
MS-DOSのディレクトリに納まらない名前のファイルやディ
レクトリをコピーせず無視します.このオプションは
-B オプションと -C オプションを覆います.
-L ファイルやディレクトリを元の名前でコピーする場合に,
小文字を含む名前のファイルやディレクトリをコピーし
ません.
-U ファイルやディレクトリを元の名前でコピーする場合に,
コピー先の名前を大文字にします.
関連事項
ln(1), mv(1), rm(1), mkdir(1), chmod(1)
診断
何らかのエラーがあったときにはエラー・メッセージが標準エラー
出力に出力されます.
終了ステータスとしては,引数の記述に間違いがあった場合には 1,
各引数の処理中に何らかのエラーが 1度でもあった場合には 2,メ
モリ不足や OS のバージョンの違いなど,システムの原因により正
常に実行ができなかった場合には 3,すべてが正常に終了したなら
ば 0 が返ります.^C などによって中断したときの終了ステータス
は OS の仕様によります.
注意
ファイルのコピーに失敗したり,ファイルのコピー中に ^C によっ
て停止した場合には,コピー先にコピー途中のファイルが残ります.
不具合
サブディレクトリに別のドライブがjoin(mount)されているとき,
-x オプションはその別ドライブ内のファイルやディレクトリを無
視しますが,そのサブディレクトリそのものだけはコピーされます.
ディレクトリの再帰の回数は64回に制限されています.
バージョン
2.8
制作・著作
Copyright(C)1992-94 by 板垣 史彦 (Itagaki Fumihiko)
2.8 Last change: 8 Oct 1994 Itagaki Fumihiko