A lesson in Ubuntu history
Here are some of the basic uses of the history command:
> history
- this lists all commands you have executed in the shell
> history | more
- same as above but only shows a page of list
- press spacebar to move to the next page
- press the letter q to quit displaying history commands
- the | is a pipeline which means redirect the output of the history command as input to the more command
> history | grep <text> example: > history | grep ls > history | grep rsync
- lists only the shell commands that contains the text after the grep command
- grep basically is a command line text search utility
> man history
- help manual of the history command
- very helpful documentation I must say!
Since I started using Ubuntu, I have been wondering how do I get to issue the 100th command in the list. I looked at the manual and did not understand it at first. Just today, tired of typing a long list of rsync command, I looked at the history manual again and noticed the Event Designators section.
Event Designators
An event designator is a reference to a command line entry in the history list.
! Start a history substitution, except when followed by a blank, newline, = or (.!n Refer to command line n.and a lot more options down the line.
Out of instinct, I typed:
> history !100
and got the error message of:
bash: history: ln: numeric argument required
Giving a sheepish grin, I tried:
> !100
and the 100th command in the history list gets executed!
Talk about being silly, it took me about 2 months to finally figure that out.
Now that’s an interesting lesson in Ubuntu history ain’t it? ![]()



Recent Comments