List of commands you use most often

history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head

2009-02-11 13:12:29

6 Alternatives + Submit Alt

What Others Think

It didn't work properly for me I used "history -$HISTSIZE" against just "history" to sue the full history and not only the 10th firsts. my correction is then history -$HISTSIZE | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
yogsototh · 675 weeks and 3 days ago
since i got dates on my commands this one works better for me using the 4th column history | awk '{a[$4]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
bbelt16ag · 673 weeks and 6 days ago
use this! more portable history | awk '{a[$'`echo "1 2 $HISTTIMEFORMAT" | wc -w`']++}END{for(i in a){print a[i] "\t" i}}' | sort -rn | head
bandie91 · 670 weeks and 3 days ago
history | sort -k2,3 | uniq -f 1 -c | sort -rn | head
taliver · 635 weeks and 2 days ago
Arranges it in columns, and with a variable number of results. Use $ mostused NUMBERTOSHOW mostused() { history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | ( echo "USES COMMAND" && head -n $1 ) | column -t; }
AtkinsSJ · 613 weeks and 1 day ago
seofox · 9 weeks and 2 days ago

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? 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.


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: