Bash saves the history of commands used. The history of these commands is stored in the. bash_history file of the user's main directory.
Introduction
Bash saves the history of commands used. The history of these commands is stored in the. bash_history file in the user's main directory.
========================================================== ===
Search for history commands
You can run the following command to view the history content list:
[Root @ allyes20121031 de_info_center] # history | less
1 [13:59:13] cd/www/de_info_center
2 [13:59:14] ll
3 [13:59:59] cd ..
4 [14:00:02] cd de_info_center
5 [14:00:03] pwd
6 [14:16:58] ps-A | grep "de_info"
7 [14:17:01]./de_information_center
8 [14:17:11]./de_information_center start/www/de_info_center/de_information_center_config.txt
9 [14:17:14]./de_information_center
(END)
========================================================== ===
Use! Row number
Assume that the command 2 [13:59:14] ll is found. We can use it! 2, to quickly use the command for this line.
[Root @ allyes20121031 de_info_center] #! 2
Ll
Total 2660344
-Rw-r -- 1 root 2594 May 15 13:05 argv. cpp
-Rw-r -- 1 root 1296 May 14 argv. h
-Rw-r -- 1 root 5001 May 13 config. cpp
-Rw-r -- 1 root 5382 May 13 13:56 config. h
========================================================== ===
More history extensions
!! : Repeat The Last Command.
! Row number: execute the command line n in the record.
! String: repeat the recent historical commands starting with string.
!? String: repeat recent historical commands that contain strings.