
man
コマンド(たとえば)がレコードに表示される回数を数えたいです。
答え1
現在も使用できます。history
$ history | grep -cw man
すべてのコマンドをカウントします。
$ history | awk '{c[$2]++}END{for (x in c) print c[x],x | "sort -n"}'
...
9 grep
9 ssh
10 ping
17 mv
19 mkdir
21 svn
35 perl
43 cd
46 python3
71 ls
96 vi
答え2
現在のユーザーの履歴は、bashを使用している場合はファイルにあり、~/.bash_history
zshを使用している場合は~/.zsh_history
。
これで、簡単な方法を使用してgrep -cw man ~/.bash_history
単語を含む行数を取得できますman
。
コマンドが 1 行で複数回使用されるたびに、履歴ファイルには一度だけ表示されます。