linux run command from history code example

Example 1: history command linux

Highly recommended command to use in terminal for reviewing commands and reuse
some of them. Just execute in terminal:

history

Also recommended to use together with grep for filtering a specific used command

history | grep "foo*"

Example 2: how to run a command from history linux

##To run a specific command from your history by its number, use the following command:
!#

##Example to run command number 12 from history list enter below command
## Replace the number with ur required command from bash history.
!12

## To just display what exact command would be executed without actually executing it
!12:p