2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

中身は消さずにディレクトリだけ消したい

Posted at

SS 192.png  ディレクトリがマトリョーシカみたいになっちゃった。

やること

[A]親ディレクトリ
 └[B]削除したいディレクトリ
   └[C]子ディレクトリ

となっている時に、[B]を外して、

[A]親ディレクトリ
 └[C]子ディレクトリ

とする。

環境

  • Linux

やり方

$ cd [A]親ディレクトリ

まず [A]親ディレクトリ の中に移動する。
この時、$ ls とすると [B]削除したいディレクトリ が見えているハズ。

$ mv ./[B]削除したいディレクトリ/* ./

次に、[B]の中身全部(つまり[C])を、[A]の直下に移動する。
[B]と[C]が同じ階層に並ぶ。

$ rm -rf [B]削除したいディレクトリ

空になった[B]を削除する。
[注意] ワイルドカード*で拾えないファイルがあった場合はそれも削除されるので注意。

2
4
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
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?