Section Next | Prev


2.4.4 ファイルのコピー(cp)

【機能説明】
コマンド cp は、 file1 を file2 にコピーします。 file2 の属性は cp を実行したユーザの環境で書き換わります。
2 番目の形式では複数のファイルを、 指定したディレクトリに同じ名前でコピーします。
特に指定しない限り、名前が重複したコピー先ファイルは上書きされます。

【入力フォーマット】
cp [ オプション ] ファイル1 ファイル2
cp [ オプション ] ファイル1 ... ディレクトリ

【主なオプション】
-i (information/interactive)
出力ファイルがすでに存在しているとき、上書きの確認をします。

-r/-R (recursive)
指定したディレクトリの下にある全てのファイルをコピーします。 出力ファイルはディレクトリでなければなりません。
-r と -R は同じ扱いとなります。tips

-p (preserve)
コピー元となったファイルの属性を保持します。

【実行例】
ファイルをコピーします。
	[student@h006 ~]$ cp name.list name.list2
ファイル name.lis1 と name.lis2 を work ディレクトリにコピーします。
	[student@h006 ~]$ cp name.lis1 name.lis2 work/ 
ファイルの属性保持したままのコピー
	[student@h006 ~]$ cp data0 data1
	[student@h006 ~]$ cp -p data0 data2
	[student@h006 ~]$ ls -l data*
	-rw-rw-r-- 1 student student 43  7月 15 12:32 data0
	-rw-rw-r-- 1 student student 43  7月 15 12:32 data1
	-rw-rw-r-- 1 student student 43  7月 15 12:32 data2


Section Next | Prev

Copyright 2007-2018 ycosSystems GettingStart/Body244.html