1, command history
history history [options] [command] to save the file
Options: -c Clear History command
-w the cache write history command history command to save the file
~/.bash_history
Command history is saved by default 1000, you can configure the environment variable file / etc / profile modifications in effect after the value of re-login
2, command completion
When the input can use the Tab key will auto-complete (either input or command files can be used)
3, aliases and shortcuts
Alias = alias 'original command' # Aliases setting command (alias not identical to the original command)
Query command aliases alias #
Let alias permanent
vim / current username /.bashrc
Delete an alias
unalias alias
Bash Keyboard Shortcuts
4, input and output redirection
1) standard input and output
2) output redirection (provided that the command must redirect the output to have output)
3) Input redirection
wc [options] [filename] (wc typing input and press Ctrl + d have statistical functions)
Options: -c count the number of bytes
-w count the number of words
-l count the number of rows
5, multi-character command execution order of the pipe
1) multi-command
2) pipe symbol
Format: Command 1 | 2 # command command correct output 1 (must be correct output) operation as a command object 2
如 :ll -a /etc/ | more
netstat -an | grep ESTABLISHED
#netstat is to look into all network-related information
#grep [options] "Search Content" filename
Options: -i Ignore case
-n output line number
-v reverse lookup
--color = auto search for a keyword with color display
6, wildcards and other special symbols
1) a wildcard (to match the file name)
2) Bash other special symbols
7, user-defined variables
1) variable is set to rule
Variable names can consist of letters, numbers, underscores, but can not start with a number. If the variable name is "2name" it is wrong
在Bash中,变量的默认类型都是字符串型,如果要进行数值运算,必须指定变量类型为数值型
变量用等号连接值,等号左右两侧不能有空格
变量的值如果有空格,需要用单引号或双引号引着
变量的值中,可以使用“\”转义符
变量可以叠加,需要用“”包含“$变量名”或者${变量名}包含
可以把命令的结果作为值赋予变量,但需要使用反引号或者$()包含命令
环境变量名建议大写,便于区分
2)变量分类
用户自定义变量
环境变量:这种变量中主要保存的是和系统操作相关的数据
位置参数变量:这种变量主要是用来向脚本当中传递参数或数据的,变量名不能自定义,变量作用是固定的
预定义变量:是Bash中已经定义好的变量,变量名不能自定义,变量作用也是固定的
用户自定义变量
环境变量
用户自定义变量只会在当前的Shell中生效,而环境变量会在当前Shell和这个Shell的所有子Shell当中生效
设置环境变量
export 变量名=变量值 #申明变量
env # 查询变量
unset 变量名 #删除变量