1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Linux][command] ディレクトリ・ファイル管理_ファイル操作_cp, mv, touch

Last updated at Posted at 2025-02-28

cpコマンド

$ cp [オプション] コピー元 コピー先
オプション 由来 説明
default copy - 指定したファイルをコピーする
-r
-R
recursive - ディレクトリを再帰的にコピーする
-p preserve - コピー元のファイルの属性(パーミッション、所有者、タイムスタンプなど)を保持したままコピーする
-i interactive - 既存のファイルを上書きする際に確認を求める
-f force - 書き込み権限がない場合でも強制的にコピーする

mvコマンド

$ mv [オプション] 移動元 移動先
オプション 由来 説明
default move - ファイルやディレクトリを移動またはリネームする
-i interactive - 上書きの際に確認を求める
-f force - 上書き時に確認せず強制的に移動する(-iより優先)
-v verbose - 処理内容を詳細に表示する

touchコマンド

$ touch [オプション] ファイル名
オプション 由来 説明
default なし - 指定したファイルのタイムスタンプ(アクセス日時、変更日時)を現在の日時に更新する
- 指定したファイルが存在しない場合、ファイルを新規作成する
-c no-create - 指定したファイルが存在しない場合、新規作成を行わない
-t timestamp - 明示的に指定したタイムスタンプに変更する(例:touch -t 202301010101 file.txt
-a access time - アクセス日時のみを変更する(変更日時は変更しない)
-m modify time - 変更日時のみを変更する(アクセス日時は変更しない)

Ping-t

cp

mv

touch

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?