1
1

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.

freeコマンドの結果を見やすくする

Last updated at Posted at 2015-12-25

freeコマンドはしょっちゅう使うけれど、個人的に視認性がいまいちだと思っていたので、perlのワンライナーで見やすく表示できるようにしてみました。
ちなみに、ワンライナーにこだわったのは、IMEに登録してどのマシンでも即実行できるようにしたかったからです。

環境

CentOS5, CentOS6
※CentOS6.7以上の freeは -h オプションが使えるので適宜書き換えてください。

実行結果

$ free -m|perl -a0pe'@a=map{$_>1024?sprintf"%.1fG",$_/1024:$_.M}@F[7,15,16];$_="@a\n"'
2.0G 151M 1.8G

左から、total, buffers/cacheのused, buffers/cacheのfreeです。

謝辞

terateil にて素晴らしい回答を下さったcrhg さん、arguis さんに感謝いたします。

1
1
7

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?