history | awk '{CMD[$4]++;count++;} END { for (a in CMD )print CMD[a] " " CMD[a]/count*100 "% " a }' | sort -nr | nl | column -t | head -n 10

statistic of the frequnce of your command from your history。

perhaps you should use CMD[$2] instead of CMD[$4]
Sample Output
1    1928  19.28%  ll
2    1341  13.41%  cd
3    1127  11.27%  ls
4    576   5.76%   cat
5    364   3.64%   vim
6    243   2.43%   ssh
7    211   2.11%   vi
8    196   1.96%   pt-table-sync
9    189   1.89%   rm
10   186   1.86%   mysql

0
By: jasee
2013-07-05 02:38:04

These Might Interest You

  • Note the space before the command; that prevents your history eliminating command from being recorded. ' history -c && rm -f ~/.bash_history' Both steps are needed. 'history -c' clears what you see in the history command. 'rm -f ~/.bash_history' deletes the history file in your home directory.


    2
    history -c && rm -f ~/.bash_history
    unixmonkey6650 · 2009-10-16 13:48:20 1
  • This could be added to .bashrc. Background: Linux usually saves history only on clean exit of shell. If shell ends unclean, history is lost. Also numerous terminals might confuse their history. With this variable set, history is immedeately written, accessible to all other open shells.


    2
    PROMPT_COMMAND="history -a"
    danam · 2009-10-21 12:33:25 0
  • eh stands for Edit History . Frequently, I'll mistype a command, and then step back through my history and correct the command. As a result, both the correct and incorrect commands are in my history file. I wanted a simple way to remove the incorrect command so I don't run it by mistake. . When running this function, first the ~/bash_history file is updated, then you edit the file in vi, and then the saved history file is loaded back into memory for current usage. . while in vi, remember that `Shift-G` sends you to the bottom of the file, and `dd` removes a line. . this command is different than bash built-in `fc` because it does not run the command after editing.


    7
    eh () { history -a ; vi ~/.bash_history ; history -r ; }
    unixmonkey8121 · 2011-03-23 18:00:20 5
  • Note the extra space before the command (I had to put it as an underscore since the website eats up preceding spaces). That's all it takes. Now if you check your history with "$ history", it wont show up.


    5
    _cd ~/nsfw; mplayer midget_donkey.mpeg
    Kirbe · 2009-02-16 17:19:40 6
  • If the HISTTIMEFORMAT is set, the time stamp information associated with each history entry is written to the history file, marked with the history comment character. Show Sample Output


    0
    echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
    99RedBalloons · 2013-09-19 03:25:14 0
  • By defining a function "gh" as shown here, it saves me typing "history | grep" every time I need to search my shell history because now I only have to type "gh". A nifty time saver :-) You can also add the "gh" function definition to your .bashrc so it is defined each time you login. (updated 2015_01_29: changed from hg to gh to avoid clash with that other hg command. mnemonic: gh = grep history) Show Sample Output


    4
    function gh () { history | grep $* ; } # gh or "grep history"
    mpb · 2014-04-02 15:17:31 4

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: