View The Most Used Commands Within Terminal 0


View The Most Used Commands Within Terminal


I frequently use Terminal for the various tips and tricks on this site. Today’s post (e-mailed in by a reader) is a quick Terminal command which you can use to find out which Terminal command you have used the most often. This trick is a great way of seeing which command you are using frequently, and if you need to add it to a shortcut. It won’t give you the full command, but it will however give you the main bit. For example if you use the cd command to change directory, it will list cd rather than the files listed under the cd command.

To use this command open up Terminal. Copy and paste the following into the dialogue box and hit enter.

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

A second later it will output the top twenty commands used within Terminal. If you want to see more or less commands, alter the number at the end of the command to however many you want.

The output is quite useful to see. My most used commands are crush, for reducing images sizes, change directory and the defaults command for changing preferences. None of these come as a surprise. The command will also list the number of times it appears.

This command searches through your history. So if you have recently deleted your history or don’t have many entries, the output will be quite sparse.

If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

Where To Next?

  • Subscribe To Mac Tricks And Tips