1
0

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.

historyで最も使ってるコマンドを取得する

Last updated at Posted at 2018-07-11

historyコマンドを使えば最近使ったコマンドを一覧にして見ることができますが、これを更に使いやすくするために少し試しにやってみました。

使った頻度順に並べる

$ history | cut -d' ' -f 4 | sort | uniq -c | sort -nr

最初の10件だけを取得する

$ history | cut -d' ' -f 4 | sort | uniq -c | sort -nr | head -10

gitでどのコマンドを一番使ってるかを調べる

$ history | cut -d' ' -f 4,5 | awk '$1=="git" {print $2}' | sort | uniq -c | sort -nr

awkを使えばcutした後の第1列目が「git」であるときのみ、その第2列をprintする形にすれば、gitに絞ってソートできます。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?