Shell History Commands
While interacting with terminal, you'll be typing some commands very often and sometimes typing with variations on those commands. Sometimes it can be very irrritating as well as a little bit time consuming.
Luckily, shell provides some commands to repeat the history of the commands used. Shell makes it easy for us to repeat the commands we have used. Once you'll learn how to use those commands effectively, you can save a lot of time in typing the commands.
Shell History Search Command
|!! (bang bang)||Repeats last typed command. |
|!(one or two letters from starting of command) (bang)||To repeat other commands other than last typed command.|
|history||Shows a list of older commands.|
|!n||Repeats the command at line number n.|
|Ctrl -r (three or four characters from starting of command)||Repeats the mentioned command.|
|$HISTSIZE||Determines number of commnds stored in the history.|
|$HISTFILE||Displays location of file that contain histoty.|
|$HISTFILESIZE||To set numbet of commands stored in history file|
Keys In History Command:
- UP arrow key : Will scroll you backwards in history.
- ctrl + p : Will scroll you backwards in history.
- DOWN arrow key : Will scroll you downwards in history.
- ctrl + n : Will scroll you downwards in history.
- ctrl + r : Will take you to the command including the specified character.
- ctrl + g : Escape from history searching mode.