Shell-based pipe characters and variables

Source: Internet
Author: User

Pipe characters and variables

One, the pipe character and the job command

1.txt |wc–l; Cat 1.txt|greap ' AAA '

The command for the pipe character is to give the result of the previous output to the following command

2.ctrl z pause a task

3.jobs viewing tasks in the background

4.bg[id] Move the task to the background so that it runs in the background background run multiple tasks to use BG 1 bg 2If no parameter is the default last running program

5.fg[id] to the front desk, restore the task, to the front desk to foreground, run multiple tasks can use FG 1 FG 2 to Restore the task, to the front desk to foreground, Running multiple tasks can use FG 1 FG 2

7. command to add & Drop the task to the background directly

Second, the variable

1. PATH,HOME,PWD,LOGNAME

Common environment variables:

PATH determines to which directories the shell will look for commands or programs

Home Current User home directory

Histsize number of historical records

LOGNAME The current user's login name

HOSTNAME refers to the name of the host

Shell Front user shell type

LANG Language-related environment variables, multiple languages can modify this environment variable

Mail Storage directory for the current user of mail

PWD Current directory

2. Env command:env command to list all system variables of system presets

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

4. Custom Variable a=1

Variable rule:

A. the format of the variable is "a=b", where a is the variable name,b is the contents of the variable, there can be no space on either side of the equal sign;

B. variable names can only consist of English, numerals, and underscores, and cannot begin with a number;

C. when the contents of a variable are marked with a special character (such as a space), a single quotation mark is required, and the contents of the variable are enclosed in single quotes, which requires double quotation marks.

D. if the contents of the variable need to use other commands to run the result, you can use the back quotation marks;

E. variable content can accumulate the contents of other variables, need to add double quotation marks;

F. variable name rules: Letters, numeric underscores, first digits cannot be numbers

5. Accumulation of variables

6. Global Variables export b=2

Export is actually declaring the meaning of this variable, so that the Shell 's child shell also knows what the value of the variable is . if you do not add any variable names after export, it declares all variables.

7. Unset Variable: What if you want to cancel a variable? Simply enter "unset variable name " to


Shell-based pipe characters and variables

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.