Pipe and job control, shell variables, environment variable profiles

Source: Internet
Author: User

One, pipe and operation control

1. Pipe character: | (The result of the previous command output to the following command)
Count the number of files after the ls command: LS |wc-l
List the number of files in the/etc/directory: find/etc/-type f |wc-l

2. Job Control:
CTRL + Z pauses a task,
Restore with command: FG
If there are multiple pause tasks, we can restore a task with FG +id
Jobs lists tasks that have been paused
BG +id, let it run in the background.
Vmstat 1 (Let the system display some information constantly)
Sleep 1000 Pause 1000s
Sleep & Let It go back to work
To view a process's commands: PS aux |grep sleep

Second, shell variables
1. Variables: PATH, HOME, PWD, LOGNAME
2?
ENV command: View the name of the system variable
Set command: View system and user-defined variables
3. Custom variables:
Cases:
a=2222
Echo $a

4. Rules for variable names: The first cannot be numbers, letters, numbers, underscores;
When a variable has a special symbol, enclose it in single quotation marks.

5. Accumulation of variables:
A=1
b=2
Echo $a $b

A= "$b" C
B=3
Echo $a $b

6. Global variables
Export b=222

7. Cancel the variable.
unset + variable Name
Unste b

Iii. configuration files for environment variables
1. System level (/etc/below)
/etc/profile User Environment variables, interactive, log on automatically run
/ETC/BASHRC users do not log on, execute the shell automatically run

2. User level (/root/below)
?/.bash_profile
?/.BASHRC

The difference between profiles and BASHRC is that profile is automatically loaded when the user logs on to the system, and BASHRC is called when the shell script is executed, BASHRC files are invoked.
?/.bash_logout is used to define some of the actions that a user needs to make when exiting;

3, $PS 1 variables: (that is, the content in front of our command prompt)
Defined in the/ETC/BASHRC,
1?echo $PS 1
2, we can change its variables, the example of removing it [],
Ps1= ' \[email protected]\h \w\$ '
If you change the BIG W to small W, the directory behind it becomes the absolute path.

There's another environment variable: PS2
Echo $PS 2

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.