Shells designed to be used interactively allow you to recall and edit previous commands, generally with the Up and Down keys. You can often search a string in the command history with Ctrl+R and Ctrl+S, too.
Some shells have a different feature, known as history expansion (bash), history substitution (tcsh) or history expansion (zsh): sequences beginning with
! are replaced by substrings from previous commands, for example
!! | less repeats the previous command and pipes it into