24, pipe and job control, shell variables, environment variable configuration file

Source: Internet
Author: User

24, pipe and job control, shell variables, environment variable configuration file
One, pipe and operation control
Pipe Break: | Indicates that the contents of the previous file output are passed to the following command.
|grep: Filter, specify the keyword command. |grep ' AAA '.
Job Control
CTRL + Z: Pauses a task. It is equivalent to placing the current task in the background, using the FG command to recall the task. FG: Front desk, foreground. BG: Backstage, the task is transferred to the background to run. Example:

vim/etc/passwd

[1]+ has stopped vim/etc/passwd
You can stop multiple tasks and the suspended tasks will be numbered.
Which is to be recalled to FG 1 or FG 2. fg+ number can be. The last task is performed without numbering.
Jobs command: List the stopped tasks.
Sleep command: Pauses the specified time. The length of time, which can be followed by S, M, H or D, where S is seconds, M is minutes, H is hours, and D is the number of days.

Sleep 1000

^z
[1]+ has stopped sleep 1000

Sleep 1250

^z
[2]+ has stopped sleep 1250

Jobs

[1]-has stopped sleep 1000
[2]+ has stopped sleep 1250

BG 2

[2]+ Sleep 1250 &

Jobs

[1]+ has stopped sleep 1000
[2]-Run in sleep 1250 &
&: After adding this symbol, the command is dropped directly into the background.

Sleep &

[1] 1253

Jobs

[1]+ Run in Sleep &
Commands that run in the background of the current terminal are not visible in the other terminal, but the process can be seen.
Second, shell variables
Variable: path,home,pwd,logname
ENV command: Lists all system variables that are preset by the system, and the system variables are generally uppercase letters in English. Example:

There are these system variables in the Env list.

Xdg_session_id=1
Hostname=yaowei-01
Selinux_role_requested=
Term=xterm
Shell=/bin/bash
histsize=5000
ssh_client=192.168.93.1 64290 22
Selinux_use_current_range=
ssh_tty=/dev/pts/0
User=root
Path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
Pwd=/root
Lang=zh_cn. UTF-8 en is English, ch is Chinese, and UTF-8 is character encoding.
Selinux_level_requested=
Histcontrol=ignoredups
Shlvl=1
Home=/root
Logname=root
ssh_connection=192.168.93.1 64290 192.168.93.130 22
lessopen=| | /usr/bin/lesspipe.sh%s
Xdg_runtimedir=/run/user/0
=/usr/bin/env
SET command: Output environment variable. You can view not only the environment variables of the system presets, but also the user-defined environment variables.
Variable name rules: Letters, numeric underscores, and the first cannot be numbers.
The value of a variable must be enclosed in single quotation marks when it has a special symbol.
For example A= ' a B C ' characters with spaces, you need to enclose them in single quotation marks. Otherwise it will not take effect. Double quotation marks are also possible, but some special symbols will be treated as a token by the system and will not take effect, such as the $ symbol.
The summation of variables

A=1b=2echo $a $b

12

A= ' A$BC ' echo $a $b

A$bc2

C= "A$BC" Echo $c

A there's no recognition here $BC.

C= "A$b" C so to enclose the a$b separately, it is not possible to use single quotes here, it will think $ is a symbol. Echo $c

A2C is set up in front of b=2
Multiple variables can be enclosed in double quotation marks when they overlap each other. # c=a "$b" C
Global Variables Export b=2
Export variable name = variable value, the command is to declare this variable.
The previously set variables are actually local and only take effect under the terminal, and can be changed to global variables once using export. Under this shell can be effective all the time, at other terminals will not take effect.
Cancel a variable: unset followed by the name of the variable
III. environment variable configuration file
Two dimensions: System level, User level.
System level: Is the file under/etc.
/etc/profile: User environment variable, interactive, login is not executed.
/ETC/BASHRC: The user does not have to log on, the execution shell takes effect.
User level: Files under the user's home directory. ~/.bashrc
~/.bash_logout: Used to define what needs to be done when the user exits.

24, pipe and job control, shell variables, environment variable configuration file

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.