Linux Summary bash features
- Command history:
- Use command: History
- Environment variables:
- Histsize: The number of bars recorded in the command history buffer, which defaults to 1000;
- Histfile: Record the current logged-in user logout the history command to store files;
- Histfilesize: Command history file records the number of history, the default is 1000;
- Operation Command History:
- History d offset deletes the command histories for the specified line;
- History c empties the command in the historical buffer of the command;
- History # shows the most recent # commands from the past;
- History a manually appends the commands in the current session buffer to the historical file;
- To invoke a command in history:
- !#: Execute the # command repeatedly;
- !: Repeat the previous one (last command;)
- !string: Repeats the last command that begins with the specified string;
- Call the last parameter of the previous command:
- !$
- ESC,.
- Control how the Command history is recorded:
Environment variable: Histcontrol
Three values:
Ignoredups: Ignoring duplicate commands; the so-called repetition must be continuous and identical, including options and parameters;
Ignorespace: Ignores all commands that begin with whitespace, not records;
Ignoreboth: Ignore the above two items, both ignore the duplicate command, also ignore the beginning of the blank command;
How to modify environment variables:
Export variable name = "VALUE"
Or: Varname= "VALUE" Export VARNAME
- Command completion:
Internal command: Directly through the shell completion;
External command: Bash searches for a file named for a given command from left to right, based on the path defined by the PATH environment variable, and is the command to be executed the first time it is found;
Note: After the first search through path to the command, it will be stored in the hash cache, the next use no longer search path, from the hash to find;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/4B/wKioL1X5hEzzQS9kAABk0PRn_p0242.jpg "/>
TAB completion:
If the user-given character is in the command search path and only one command matches it, the TAB key is directly complete;
If the character entered by the user has more than one command in the command search path, the TAB key can be used to list the commands again;
- Path Completion:
Begins with a string entered by the user as a path and searches the parent directory of its specified path for the file name beginning with the specified string;
If the only, then direct completion;
Otherwise, tab again to list all eligible paths and files;
- Command line expansion:
1) ~: Expand to the user's home directory;
2) ~username: Expand the home directory for the specified user;
- {}: Can host a comma-delimited list and expand it to multiple paths;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/4E/wKiom1X5ghXjx1xnAAIhgWZ-TJY902.jpg "/>
- Execution result status of the command:
Success or failure;
Bash uses a special variable $? Save the execution status result of the most recent command;
Value: 0: Success;
1-255: Failure, 1,127,255 for system retention;
Program execution has two types of results:
The return value of the program, the output of the execution of the program itself;
The execution status result of the program;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/4B/wKioL1X5hEzRy0YxAAC4pEGbbPg461.jpg "/>
- Command Aliases (alias)
- Implemented by the alias command:
- Alias displays all the available command aliases for the current shell process;
- Define alias: Alias Name= ' VALUE ' defines the alias name, which executes equivalent to executing the command value,value can contain commands, options, parameters;
- To define a command alias by modifying the configuration file:
Current User: ~/.BASHRC
Global Users:/ETC/BASHRC
The bash process re-reads the configuration file:
Source/path/to/config_file
. /path/to/config_file
Revoke alias: Unalias
Unalias [-A] name [name ...]
Note: For commands that define aliases, use the original command to use the \command
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/4E/wKiom1X5ghWxezqqAAElGCXjhXQ773.jpg "/>
- Glob (globing)
Used in bash to implement file name "wildcard"
Wildcard characters: *,? ,[]
- * Arbitrarily from any character of length;
A*b:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/4B/wKioL1X5hEyzG0ZcAABZR9w8jaU069.jpg "/>
- ? any single character;
A?b:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/4E/wKiom1X5ghXAVsKyAABhFmbHlls990.jpg "/>
- [] matches any single character within the specified range;
[0-9] [A-z] is case insensitive
[admin] can be in the form of an interval, or it can be discrete;
4) [^] matches any character outside the specified range;
[^0-9] Any character of a single non-digit;
Dedicated Character Set:
[:d igit:] Any single number equivalent to [0-9]
[: Lower:] Any single lowercase letter,
[: Upper:] any single capital letter;
[: Alpha:] Any single case of uppercase and lowercase letters;
[: Alnum:] any number or letter;
[: space:] any white space character;
[:p UNCT:] any single special character;
Note: When using [] to reference a dedicated character set, the outer layer also needs to be nested []. For example:
# ls-d/etc/l*[[:d igit:]]*[[:lower:]]
- Bash shortcut keys: