Shell: The interface of the man-machine exchange, the related commands are processed and submitted to the kernel, and the kernel is then driven by the system call hardware execution.
Shell's classification:
Gui:gnome,kde,xfce
Cli:sh,csh,ksh,bash,tcsh,zsh
The concept of the program:
The program is a compiled binary executable file
Concept of the process:
A process is a copy of a program, a program execution instance, and in each process it appears that only the kernel and the current process exist on the current host
Features (or functions) of bash:
1. Command line history, command line completion
2. command-line editing
3. Command aliases
4. Command replacement
5. File name Wildcard
6. Piping, I/O redirection
7. Variables
8.shell programming
1. Command line history, command line completion
History: View command-line histories (records are temporarily saved in memory buffers)
-C: Clear command history
-D Number: Delete the command at the specified location
-W: Save command History to home directory history file (. bash_history) When exiting the login, the command line history in the memory buffer is written to. bash_history
The use of command history tips:
!n: Executes the nth command in the command history;
!-n: Executes the reciprocal nth command in the command history;
!! : Execution of the previous order;
!string: Executes the most recent command in the command history that begins with the specified string;
!$: References the last parameter of the previous command;
Press ESC to release and press. and ALT +.: Reference the last parameter of the previous command
Ctrl+r key: Search command line history and press ENTER to execute quickly
Historical command-related environment variables:
Histfilesize defines a command entry that is saved in a. bash_history file
Histsize defines the maximum number of entries that the history command can display
Histtimeformat defines the time format for the history command, which is typically configured histtimeformat= '%F%T '
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6F/F4/wKioL1WuPqGjZ2HZAACV_5PPq58884.jpg "title=" History command "alt=" Wkiol1wupqgjz2hzaacv_5ppq58884.jpg "/>
Command line completion:
Command completion: Searches for the executable file at the beginning of each path specified by the PATH environment with the string we give, and if more than one, press two tab to give the list, otherwise the unique command will be directly complete.
Path completion: Searches for each filename under the starting path we give, and tries to complement it.
2. command-line editing
Common key combinations:
Ctrl+p: equivalent to ↑ key
CTRL + N: Quite with ↓ key
Ctrl+b: equivalent to ← Key
Ctrl+f: Equivalent → Key
Ctrl+e: Jump to end of line
CTRL + A: Jump to the beginning
Ctrl+u: Delete all the contents of the left side of the cursor in a row
Ctrl+k: Deletes the entire contents of the cursor to the right (containing the characters specified by the cursor) in a row
3. Command aliases
Alias: type alias directly to display the aliases available under the current shell
Alias string= ' CMD [options] [arguments] '
Aliases defined in the shell are valid only for the current shell life cycle, and the valid range of aliases is only the current shell process
Ualias STRING: Deleting aliases
If string is originally a command, \string means ignoring the alias and executing the original string directly.
4. Command replacement
Command substitution is the output of using another command in one command, such as COMMAND1 ' COMMAND2 '
$ (command) ' command '
Quotes supported by bash:
': Anti-quote, for command substitution
"": double quotes, weak references, you can implement variable substitution, replace the variable with the value of the variable
': Single quote, strong reference, cannot implement variable substitution
5. File name wildcard (globbing)
*: Any character of any length
?: any single character
[]: matches any single character within the specified range
[A-z] [A-z] [A-za-z] [0-9a-za-z]
[[: Space:]]: white space characters
[[:p UNCT:]]: punctuation
[[: Lower:]]: lowercase letters
[[: Upper:]]: Uppercase
[[: Alpha:]]: Uppercase and lowercase letters
[[:d Igit:]]: Number
[[: Alnum:]]: Numbers and uppercase and lowercase letters
[^]: matches any single character outside the specified range
6.I/O Redirection, piping
Common input Devices: keyboard, mouse, hard disk, etc.
Common output devices: monitors, stereos, hard drives, etc.
System settings:
Default output device: Standard output, stdout,1
Default input device: standard input, stdin,0
Standard error Output: stderr,2
Standard input: Keyboard
Standard output and Error output: Display
I/O redirection:
Overwrite output, transfer output to specified other place
>>: Append output
SET-C: Prohibit overwrite redirection for already existing files;
Force overwrite output, use >|
Set-c: Turn off the above features
2>: Redirect Error output
2>>: Append method
&>: Redirect standard output or error output to the same file
<: Input redirection
Example: Cat>catfile<etc/profile
<<: End of input symbol
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/F7/wKiom1WuTyPh20OAAABI2WuLWCA818.jpg "title=" input redirection " alt= "Wkiom1wutyph20oaaabi2wulwca818.jpg"/>
Pipe: The output of the previous command, as input to the latter command
COMMAND1 | COMMAND2 | COMMAND3 ...
Example: cut-d:-f1 | head-1 | Id
7. Variables
Variable: A memory space that can be understood as a named
Memory: Addressable storage unit
Variable type: Determine the storage format and length of the data in advance
Character
Numeric type
Integral type
Floating point Type
Boolean type
Bash Variable categories:
Environment variable: scope is the current shell process driver process
Export Varname=value
Varname=value
Export VARNAME
Local variables: scope for the entire bash process
Set Varname=value
Local variables: Scope is the current code snippet
Local Varname=value
Positional variables: The parameters passed when the shell is programmed, the first parameter in the. sh file can be represented as $ $, and the second is $ ...
Special variables:
$?: Execution status of previous command return code (0-255)
0: Correct execution
1-255: Error execution, 1, 2, 127 system reserved
Variable operation
Undo Scalar: Unset VARNAME
View all variables in the current shell: set
To view environment variables in the current shell:
Printenv
Env
Export
Linux Learning Notes < four >--bash features