Unix-commands-cp

提供:Dev Guides
移動先:案内検索

cp-Unix、Linuxコマンド

NAME

*cp* -1つ以上のファイルを別の場所にコピーします。

概要

cp [options]... Source Dest
cp [options]... Source... Directory

説明

デフォルトでは、疎なSOURCEファイルは粗いヒューリスティックによって検出され、対応するDESTファイルも同様に疎になります。 これが—​sparse = autoで選択された動作です。 SOURCEファイルに十分な長さのゼロバイトのシーケンスが含まれている場合は常に—​sparse = alwaysを指定して、スパースDESTファイルを作成します。 --sparse = neverを使用して、スパースファイルの作成を禁止します。

SIMPLE_BACKUP_SUFFIXで設定されていない限り、バックアップサフィックスは>です。 バージョン管理はVERSION_CONTROLで設定できます。値は次のとおりです。 特別な場合として、cpは、forceおよびbackupオプションが指定され、SOURCEとDESTが既存の通常ファイルの同じ名前である場合、SOURCEのバックアップを作成します。

オプション

Tag Description
-a, --archive same as -dpR
-b, --backup make backup before removal
-d, --no-dereference preserve links
-f, --force remove existing destinations, never prompt
-i, --interactive prompt before overwrite
-l, --link link files instead of copying
-p, --preserve preserve file attributes if possible
-P, --parents append source path to DIRECTORY
-r copy recursively, non-directories as files
--sparse=WHEN control creation of sparse files
-R, --recursive copy directories recursively
-s, --symbolic-link make symbolic links instead of copying
-S, --suffix=SUFFIX override the usual backup suffix
-u, --update copy only when the SOURCE file is newer than the destination file or when the destination file is missing
-v, --verbose explain what is being done
-V, --version-control=WORD override the usual version control
-x, --one-file-system stay on this file system
--help display this help and exit
--version output version information and exit.

sample.txtをsample.bakにコピーします。

$ cat sample.txt
This is a sample file
$ cp sample.txt sample.bak
$ cat sample.bak
This is a sample file

サンプルディレクトリをホームディレクトリにコピーする

$ cp -f/user/sample/* >

link:/cgi-bin/printpage.cgi [__印刷]