When working a lot with command line utilities, I usually find myself retyping certain commands. This fact is a good reason for someone to use aliases to save typing time and errors.
At first we have to check our most loved/typed commands. This can be done using:
history | cut -c 8- | sort | uniq -c | sort -nr | head -20
After analyzing the output, we can decide which commands could be substituted by aliases, insert them in the ~/.alias file and use them after we “source” it .
 Explanation of the commands used:
- history: show the last commands entered
- cut -c 8-: cut the first 7 characters from each line of “history” output (cut off the number)
- sort: sort the commands alphabetically
- uniq -c: count same commands in a frequency table
- sort -nr: sort the frequency table by descending counts
- head -20: show only the first 20 lines
Visit The Light of the LAMP blog for more…