Pipe character and job control
- | Give the result of the previous command to the following command processing.
[[email protected] ~]# cat 1.txt |wc -l 统计行数5[[email protected] ~]# cat 1.txt |grep ‘aaa‘aaaa 剪切出aaa的行
- CTRL Z pauses a task, which can only be operated at the current terminal, and the other terminal will be able to check the process
- Jobs view the tasks in the background
- BG [ID] The task to the background, no ID default last
- FG [ID] The task to the foreground, no ID default last
- command to add & drop directly into the background,
[[email protected] ~]# sleep 200 暂停200秒^Z[1]+ 已停止 sleep 200[[email protected] ~]# jobs[1]+ 已停止 sleep 200[[email protected] ~]# fg 1sleep 200[[email protected] ~]# bg 1[1]+ sleep 200 &[[email protected] ~]# jobs[1]+ 运行中 sleep 200 &[[email protected] ~]# [[email protected] ~]# sleep 100 &[1] 2213[[email protected] ~]# jobs[1]+ 运行中 sleep 100 &
Shell variables
- Path,home,pwd,logname are all variables.
- EVN command displays the environment variables of the system
- The set command not only can view the environment variables of the system, but also can view the user-defined variables, many of which are set |less to see more convenient
- Custom variable: a=111
[[email protected] ~]# a=111[[email protected] ~]# echo $a111[[email protected] ~]# set |grep 111_=111a=111
- Rules for variable names: letters, numbers, underscores, numbers cannot be the first
[[email protected] ~]# a1=1[[email protected] ~]# a_1=2[[email protected] ~]# 1a=3-bash: 1a=3: 未找到命令
- The value of a variable must be enclosed in single quotation marks when it has a special symbol, not double quotes, and some special symbols cannot be used.
[[email protected] ~]# a=‘a b c‘[[email protected] ~]# a="a$bc"[[email protected] ~]# echo $aa[[email protected] ~]# a=‘a$bc‘[[email protected] ~]# echo $aa$bc
- The sum of the variables, if one variable refers to another variable, enclose the double quotation mark, cannot add the single quotation mark.
[[email protected] ~]# a=1[[email protected] ~]# b=2[[email protected] ~]# echo $a$b12[[email protected] ~]# c=a"$b"c[[email protected] ~]# echo $ca2c
- Global variables Export a=12 set a global variable, just down the sub-shell copy down, in its upper level shell and other terminals do not take effect, script 1 inside the nested script 2,2 can use the variables inside 1
[[email protected] ~]# w09:41:58 up 57 min, 1 user, load average: 0.00, 0.01, 0.05USER TTY FROM [email protected] IDLE JCPU PCPU WHATroot pts/0 192.168.16.1 08:48 6.00s 0.62s 0.16s w[[email protected] ~]# echo $SSH_TTY 查看自己的登录TTY/dev/pts/0pstree命令以树状图的方式展现进程之间的派生关系,显示效果比较直观
- Unset variable name---cancel variable
environment variable configuration file
Extended
- Bash_profile and BASHRC differences
- Simple Audit system
- About the meaning of Prompt_command environment variables
Pipe and job control, shell variables, environment variable configuration files