rmdirコマンド
スポンサードリンク
【説明】
指定したフディレクトリを削除する際に使用します。
オプションを付けずに実行した場合、ディレクトリが空でない場合はエラーになります。削除対象のディレクトリの配下にファイルもしくはディレクトリが存在する場合は削除出来ないことを意識しておく必要があります。
【構文】
rmdir [オプション] [ディレクトリ]
例 TEST1ディレクトリを削除します。
[root@localhost TEST]# ls -l
合計 4
drwxr-xr-x 2 root root 4096 6月 15 13:47 TEST1
[root@localhost TEST]# rmdir TEST1/
[root@localhost TEST]# ls -l
合計 0 |
→lsコマンドの詳細を見る
例 ディレクトリツリーを最下層から順番にすべて削除します。
[root@localhost test]# ls -lR
.:
合計 4
drwxr-xr-x 3 root root 4096 6月 15 13:50 TEST
./TEST:
合計 4
drwxr-xr-x 2 root root 4096 6月 15 13:50 TEST1
./TEST/TEST1:
合計 0
[root@localhost test]# rmdir -p TEST/TEST1
[root@localhost test]#
[root@localhost test]# ls -lR
.:
合計 0 |
|
|