14
14

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 5 years have passed since last update.

コマンドラインから1GB以上ディスク容量を食っているディレクトリを表示する

Last updated at Posted at 2014-08-20
du -h / | grep -E '^[0-9]+\.?[0-9]+G'

蛇足ながら解説すると、duコマンドはディスク使用を表示し、-hフラグをつけると適当な単位で表示してくれます。あとは、grep -E (-Eを忘れないようにしましょう、ハマります)で正規表現を指定するだけ。1.5G10Gなどにマッチします。

【追記】
@richmikan@github さんのご指摘で、FreeBSDのduコマンドは行頭にインデントを入れてしまうとのことでした。そのため、上記の正規表現では動作しません。
正規表現を^ *[0-9]+\.?[0-9]+Gとすることで、FreeBSD環境でも動作するようになります。
@richmikan@github さん、ありがとうございました。

14
14
2

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
14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?