Linux Learning Notes (24) Pipe and job control, shell variables, environment variable profiles

Source: Internet
Author: User

one, pipe and operation control
Cat 1.txt |wc-l; Cat 1.txt |grep ' aaa '
Enter the result of the preceding command to the following command
CTRL Z pauses a task, the task is hidden in the background, and the FG can be used to lift the task to the foreground.
Jobs view the tasks in the background

Bg[id] Move the mission to the background.
Fg[id] Move the mission to the front desk.


Can be seen in the background run does not affect the continuation of the input command, the red line is the random input characters

FG +id the command from the background to the foreground, you can ctrl +z abort the command

Command back & drop directly into the background
second, shell variables
Path,home,pwd,logname
env command view common variable values for the system

The SET command has many variables and includes user-defined variables

Custom Variable A=1

Variable name rules: Letters, numbers underline, the first cannot be a number

You need to enclose the value of a variable in single quotation marks when there are special symbols.

The summation of variables
A=1
b=2
Echo $a $b


Global Variables Export b=2



Two terminals connected to the same server, two terminals under/DEV/PTS/1 and/dev/pts/0 respectively


Environment variables set in one terminal do not take effect on another terminal
Pstree
The command displays a tree-like representation of the derivation of the process, showing a more intuitive effect.
If it is not installed, find its installation package and install it.



For example, although in a terminal, but good variable does not take effect, it is shown that this environment variable is set up by the local environment variable

Global variables, both the current terminal and the child shell are in effect after Setup
The global variables set by the child shell do not take effect on the parent shell

unset chen

Cancel Variable Chen

III. environment variable configuration file

/etc/profile user Environment variables, interaction, login only execution
/ETC/BASHRC user does not have to log on, execution shell is effective
/etc/is the system-level environment variable
~/is the user-level environment variable
~/.bashrc
~/.bash_profile
~/.bash_history//History command
~/.bash_logout//The action to be taken when exiting the login, default null

Ps1= ' [\033[01;32m]\[email protected]\h[\033[00m]:[\033[01;36m]\w[\033[00m]\$ '

PS1 defaults to [\[email protected]\h \w]\$

[] is on the left [email protected] tmp on both sides
U is root (user)
H is hostname
W is the last directory name of the current directory path
For example,/TMP/CHEN/123/will show up as 123.
Replace with lowercase w to display the absolute path of the directory
$ is the last #
Root user shown as #
Normal user display as $

 PS1=‘\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ ‘

With color display

Linux Learning Notes (24) Pipe and job control, shell variables, environment variable profiles

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.