Configuration files for pipeline operators, Job control, shell variables, global variables, environment variables, and shell global variables
Pipeline operator
Pipe character "|": Use the output of the previous command as the input of the next command .?
How many lines does one file have :?
In addition to opening the file "set nu" with vim to display the row number, you can also use pipeline characters to collect statistics without opening the file.
[root@shuai-01 ~]# cat 1.txt |wc -l1
View the number of files in the current directory:
[root@shuai-01 ~]# find ./ -type f |wc -l20
Job Control
When running a process, it is very important to pause the task and go out to another task. After the important task is done, let's do it again .?
Pause: ctrl + z?
Restore command: fg?
Termination command: Ctrl + c?
Run the following command in the background: bg?
View the Task Command: jobs?
Use vimto edit the 1.txt File
[root@shuai-01 ~]# vim 1.txt
You have something to do in the middle. (Ctrl + z)
[Root @ shuai-01 ~] # Vim 1.txt[ 1] + stopped vim 1.txt
After finishing the work, I want to resume the editing of 1.txt (fg)
Click Here Again (edit 2.txt.pdf, And put 1.txt in the background)
[root@shuai-01 ~]# bg 1[1]+ vim 1.txt &
"&": Indicates running in the background?
View jobs:
[Root @ shuai-01 ~] # Jobs [1] + stopped vim 1.txt[ 2]-stopped vim 2.txt
Shell variable
A variable consists of a variable name and a variable value .?
Variable name = variable value?
What are the preset variables and User-Defined variables of the variable subsystem?
Generally, system preset variables are in uppercase, such as HISTSIZE, SHELL, and PATH.
To view the value of a variable, run the echo command: echo $ variable name.
[root@shuai-01 ~]# echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin[root@shuai-01 ~]# echo $SHELL/bin/bash
Env command to display system environment variables
[root@shuai-01 ~]# envXDG_SESSION_ID=1HOSTNAME=shuai-01SELINUX_ROLE_REQUESTED=TERM=xtermSHELL=/bin/bashHISTSIZE=1000SSH_CLIENT=192.168.176.1 56774 22SELINUX_USE_CURRENT_RANGE=SSH_TTY=/dev/pts/0USER=root
The set command displays all the preset variables and User-Defined variables.
Custom variable rules :?
1. variable format: variable name = variable value (there cannot be spaces on both sides of the equal sign )?
2. The variable name consists of letters, underscores, and numbers, and cannot start with a number?
3. When the variable content contains special characters (Space), it must be enclosed in single quotation marks "?
Define a variable:
[root@shuai-01 ~]# a=123[root@shuai-01 ~]# echo $a123
The variable value contains spaces:
[root@shuai-01 ~]# b='shuai ao'[root@shuai-01 ~]# echo $bshuai ao
The variable contains other variables:
[root@shuai-01 ~]# c="$a""$b"[root@shuai-01 ~]# echo $c123shuai ao
The variables set above are only available in the current shell?
About global variables?
Global variables are defined in this shell and can also be used in this shell sub-shell .?
View the system process tree structure (pstree command)
[root@shuai-01 ~]# pstree |grep bash |-sshd-+-sshd-+-bash | | `-bash-+-grep | `-sshd---bash
Two separate sshds indicate logon from two terminals, and the first sshd separated bash indicates clone logon .?
Running bash in one shell will enter another shell
[root@shuai-01 ~]# pstree |grep bash |-sshd-+-sshd-+-bash | | `-bash---bash-+-grep | `-sshd---bash
The new shell is the sub-shell of the previous shell .?
Define a global variable (export) in the current shell)
[root@shuai-01 ~]# export b=123[root@shuai-01 ~]# echo $b123[root@shuai-01 ~]# bash[root@shuai-01 ~]# echo $b123[root@shuai-01 ~]# pstree |grep bash |-sshd-+-sshd-+-bash | | `-bash---bash---bash-+-grep | `-sshd---bash
The global variables defined in the current shell can take effect in the current shell and sub-shell. (In the upper-level shell and other terminals, it does not take effect )?
Delete variable (unset)
[root@shuai-01 ~]# unset b
Environment variable configuration file
Environment Variable subsystem environment variable and personal environment variable?
System environment variable configuration file :?
/Etc/profile: PATH, HISTSIZE, USER, umask?
/Etc/bashrc: PS1, umask?
Ps1: display a string starting with a command line [root @ shuai-01 ~] #
[root@shuai-01 ~]# echo $PS1[\u@\h \W]\$
Configuration file for personal environment variables?
./. Bash_profile: what will be executed at login?
./. Bashrc: can custom alias and custom variables be written into this file?
./. Bash_history: History command?
./. Bash_logout: Exit shell execution