One of the basic features of bash:
Command history: The shell process saves commands that were previously executed by the user in its session;
~]# history
The ability to customize the history can be achieved through environment variables:
The number of commands history that the Histsize:shell process can retain;
Histfile: A file that persists command history;
. bash_history
Histfilesize: The size of the command history file;
Command usage:
History [-c] [-D offset] [n]
or HISTORY-ANRW [filename]
or history-ps parameter [parameters ...]
-C: Clears the command history;
-D Offset: Delete the specified command history
-R: Reads the command history from the file to the history list;
-W: Appends the commands in the history list to the history file;
History #: Displays the most recent # command;
To invoke a command in the command history list:
!#: Once again execute the # command in the history list;
!! : To execute the last command once more;
! String: Executes the most recent command in the command history list that starts with a string;
Note: Repeated executions of commands sometimes need to depend on idempotent;
Call the last parameter of the previous command:
Shortcut key: ESC,.
String:!$
Control the way the command history is logged:
Environment variable: Histcontrol
Ignoredups: Ignore duplicate commands;
Ignorespace: Ignores commands that begin with whitespace characters;
Ignoreboth: Both are effective at the same time;
To modify the value of a variable:
Name= ' VALUE '
Shell Programming (i)