Pipe character and job control/shell variable/environment variable configuration file

Source: Internet
Author: User

Pipe character and job control

Pipe break: The result of the preceding command is passed to the following command by the pipe character.
Example

[Email protected] ~]# cat/etc/passwd|wc-l
43

Job Control: When you run a process, you can use the combination key to pause (Ctrl + Z) and then use the FG command to restore it, or the BG command to make it run in the background. In addition, it can be terminated (Ctrl + C)
The following command demonstrates;

[[Email protected] Document]# VI 1.txt (using the VI command to edit 1.txt files, enter some content after pressing ESC , use Ctrl + Z key to pause the task)
[[Email protected] Document]# VI 1.txt (CTRL + Z execution result)

[1]+ has stopped VI 1.txt
[[Email protected] Document]# jobs (view tasks that are paused in the background)
[1]+ has stopped VI 1.txt
[[Email protected] Document]# FG (will pause the program back in the background, if there are more than one suspended program, the FG command followed by the process number of the process to reply to the sequence number)
[[Email protected] Document]# BG (you can continue to enter the command by moving the program to the background to continue running.)
procs-----------Memory-------------Swap-------io-----system--------CPU-----
R b swpd free buff cache si so bi bo in CS us sy ID WA St
1 0 0 1405312 932 265172 0 0 0 0 43 53 0 0 100 0 0
0 0 0 1405312 932 265172 0 0 0 0 33 43 0 0 100 0 0
0 0 0 1405312 932 265172 0 0 0 0 29 37 0 0 100 0 0
0 0 0 1405312 932 265172 0 0 0 0 29 44 0 1 99 0 0
0 0 0 1405312 932 265172 0 0 0 0 30 41 0 0 100 0 0
Jobs (can see the status of the daemon running through the Jobs command)
[1]+ Run in Vmstat 1 &

Shell variables

env: View system Environment variables

[[Email protected] ~]# env//NOTE!! I'm intercepting some of the results here.
Path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
Pwd=/root
Lang=zh_cn. UTF-8
Selinux_level_requested=
Histcontrol=ignoredups
Shlvl=1
Home=/root
Logname=root

Set: View Custom variables

[[email protected] ~]# a=111//We'll start by customizing a variable to do the demonstration
[Email protected] ~]# echo $a
111

[[Email protected] ~]# set |less//Here we enter set to view too much information can not quickly find the information to see, we use the pipe character to view, directly search for content information can


变量名规则:字母、数字下划线、首位字符不能是数字

The value of the variable must be enclosed in single quotation marks when it has a special symbol.

[[email protected] ~]# a= ' A$BC '//If you do not do so, you will recognize the error, you can not set the form of your needs

The summation of variables

[Email protected] ~]# a=111
[Email protected] ~]# echo $a
111
[Email protected] ~]# b=222
[Email protected] ~]# echo $b
222
[[email protected] ~]# echo $a $b//directly enter the name you want to overlay
111222

Global variables
If you are using a custom environment variable alone, switching to a child shell will not find the shell you have previously customized, and here we define the non-global variable

[[email protected] ~]# Ask=linux//non-global variable, switch sub-shell will not find the results
[[email protected] ~]# export ask=linux//global variable, so after customization, switch to child shell can also find the results

It is important to note that the global variables are only useful to the child shell, and to the point where they want to work down, the upward is not working, for example, in the child shell defined global variables, then in the child shell and child shell and then back to the Koziko shell can be displayed, The first shell of the child shell is not visible.

Cancel a custom variable

[[email protected] ~]# unset ask//unset command followed by variable name

environment variable configuration file

environment variable profiles are divided into two dimensions: system level and User level
system level; (without editing the system hierarchy as far as possible)
/etc/profile (will be loaded when the user logs in,)
/ETC/BASHRC (this file is used when the user or system executes the shell script)
User level: Files in the User folder directory (editable)
~/.bashrc
~/.bash_profile
~/.bash_history
~/.bash_logout (some actions to be done when the user exits)

PS1 Environment Variables
The PS1 variable is the left side of the command to display some information, which has the login user name, hostname and current directory;

[Email protected] ~]#

By customizing the PS1 we can change the way this information is displayed such as the following we let it change color display;

Pipe character and job control/shell variable/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.