Pipe and job control, shell variables, environment variable profiles

Source: Internet
Author: User

Pipe character and job control

Pipe character
The pipe character means that the output from the previous file is passed to the following command. To display the number of files in the current directory:

`
Job Control
Ctrl Z pauses the current task (can pause multiple), can be recovered with FG, and jobs can see all of the tasks you paused, and if you pause multiple tasks and want to recover one of them, you can use FG Plus ID number, with the ID number of the two tasks being 1, 2, respectively.

·
BG can put the current running task in the background, but it is still running, but you can knock other commands at this time, FG can be restored.
·
The Sleep plus number is how many seconds the window is paused.
·
A command followed by & can be placed directly in the background to run. Other terminal windows with jobs are not visible backstage in this terminal window.
·
·
·
·
·

Shell variables

PATH, HOME, PWD, logname, etc. are all variables.
·
View variables
Env can view the environment variables commonly used in the system.
Set can view the variables of the system, and can also view user-defined variables.
·
Custom variables
Format: Variable name = variable Value
Variable name rule: it can be a letter, a number, an underscore, but the first cannot be a number.

`
Variable Value rule: you need to enclose the special symbol in single quotation marks. (special symbols include spaces)

·
The value of the variable is superimposed, such as the value of the c= variable A, b (the superimposed variable is enclosed in double quotes)

·
·
·
Global variables
W can view all the terminals that are currently logged into the system. (When the terminal is too narrow to display a row of content, will be Error w:67 column window is too narrow, then enlarge the remote terminal left and right width can be)

·
Use the following command to view your terminal name

·
We use the "Variable name = variable Value" format to customize a variable, if you change a terminal this variable will not be in the other terminal also.
·

·
or use bash to open a child shell, which is equivalent to another terminal, (you can use Pstree to see the specific terminal you're currently in) and you can't find the variable you're customizing.

·

So this variable is called a non-global variable, or a local variable.
·
·
If we can use the "Export variable name = variable Value" format to customize the variable, then the global variable, using bash to open a child shell This variable is also present, but you create a new terminal or does not exist in this variable, because the global variable is only a downward extension, This means that the shell is only in effect when the child shell of the current shell or child shell extends backwards.


·
·
·
·
·

environment variable configuration file

environment variable configuration file is divided into two kinds, one is system level, and the other is User level. Br/>/etc/profile and/ETC/BASHRC are system-level.
~/.BASHRC and ~/.bash_profile and ~/.bash_history and ~/.bash_logout are user-level, in the user home directory.
Profile is loaded into when the user logs in.
BASHRC is loaded when the user executes or the system executes some shell scripts.
The system level is best not to change, need to change we can change the user level, but this is only for the current user, if you want the complete set to take effect, it is necessary to change the system level configuration files.
~/.bash_logout is used to define what needs to be done when the user exits, and if you want the user to clear the command history each time they exit, you can put the command that deletes the command history into the file.
Let's introduce the PS1 variable,
After we log on to the system, there will be a string of strings starting with the user name, which can be divided into several segments, namely the user name, @, hostname, and the last level of the current directory.


·
We change the directory location to lowercase w, which means to show the absolute path.

·
At the same time we can make it color display,

·
The PS2 variable is used in another mode. Its string defaults to just a >.

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.