ファイル管理
-CentOS- | -Ubuntu-

ファイルを削除する

「rm」コマンド

書式
rm [オプション] ファイル
主なオプション名 説明
-r ディレクトリを削除する。
-f 確認メッセージを非表示にする。
-i 確認メッセージを表示を強制する。
ファイル 削除するファイルを指定する。-rを指定するとディレクトリを削除できる。

rmコマンドの実行(CentOS, Ubuntu)

拡張子[.txt]のファイルを削除する

$ ls *.txt
file.txt fileaaa.txt od.txt sort.txt wc1.txt
file2.txt join1.txt paste1.txt tr.txt wc2.txt
file3.txt join2.txt paste2.txt uniq.txt wc3.txt
$ rm *.txt -1-
  1. 拡張子[.txt]のファイルを全て削除する。

ディレクトリを削除する

$ ls
dir1 dir2
$ rm -r dir1 -1-
  1. ディレクトリ[dir1]を削除する。

 

参照元情報

LinuCレベル1 合格教本
LinuCレベル1 合格教本