Basic usage of the shell

Source: Internet
Author: User
Tags arithmetic operators bitwise

One: Shell introduction

1. What is a shell

The Shell's Chinese meaning is "shell," in layman's words, the shell is an interactive programming interface that uses the user input to drive the operating system kernel to complete the specified work. In addition to being a command interpreter, the shell is a high-level programming voice with variables, keywords, various control statements, supporting function modules, and its own grammatical structure. The most important function of the shell is the command interpretation, in this sense, the shell is a command interpreter.

The executable files on the 2.Linux system are categorized as follows:

Linux commands: Commands stored in the/bin,/sbin directory

Built-in commands: For efficiency reasons, some of the most common commands are constructed inside the shell

Utility: A utility or tool stored in a directory such as/usr/bin,/usr/sbin,/usr/local/bin

User program: After compiling the executable file, the user program can also be run as a shell command

Shell script: A batch file written by the Shell voice

Two: Shell variables

1. Variable naming rules

Start with a letter or underscore, and the rest can be: letters, numbers, underscores

It is advisable to follow the following specifications:

1) Start with a letter

2) Use an underscore or underline to make a connection to the word

3) The same type is distinguished by numbers

4) The best name for the file plus extension

For example: AA, Aa1, a_b.tar.gz

2. System Variables

Set and env differences: set: Show all variables, env: Environment variables

3. Assigning values to variables

Name=shenbuer

Echo $name

Delete variable unset name

(shell variable is lowercase; environment variable is uppercase)

4. Common system Variables

Path: The search path for the command

PWD: Displays the entire path name

LANG: Unzip or release the program

HOME: The path name of the user root directory

Histsize: Maximum number of items saved in the History list

PS1: Prompt 1, main prompt (default = "\s-\v\$")

IFS: Internal field delimiter for participle

Third, operator

1. Arithmetic operators

+ 、-、 *,/,%

2. Relationship operation

With (())

< less than

> Greater than

<= less than or equal to

>= greater than or equal to

= = equals

! = does not equal

&& Bitwise AND

|| Bitwise OR

3. Assignment operators

= equals Assignment

+ = plus equals

*= multiply equals

/+ except equal to

%= modulo assignment

Four, meta characters

  "Command in exchange for the execution of the order.

  $ () ibid, but it makes up for the "nesting flaw

  ~ Home Directory

  ! Take Non-

  ! History command Invocation

  ! Match last History command

  ! LS with a space to reverse the return value of the command

  @ No special meaning

# Notes

$ variable Value

$ () Same as '
${} variable name range

$[] integer calculation echo $[2+3]-*/% floating point with echo "scale=3; 10/3 "| Bc-l

% kill background process jobs number; Take the mold

^ Take non-and! Identical

  ^ Replace

& Background Execution;&& logic and

* match any length string; Calculate multiplication

() executes in a child process

-minus; interval; CD-;

_ No special meaning

+ PLUS sign;

= assigned value

| pipelines; | | Logical OR

Escape

{} Command list, note that the beginning and end of parentheses must be a space   {ls; CD/; }

[] character wildcard, matching one of the parentheses;

: null Command truth

; Multiple commands can be received: Ls;pwd;echo 123; Whether right or wrong, will continue to the last command

"Soft-cited" hard-cited

< input redirection

> Output redirection

>> Append

<< here Document

>& merging 2 and 1 outputs

, enumerate separators

. source; Current directory

/directory Separators

? Single character

Enter command execution

* Wildcard characters: any character
Wildcard characters: any character
One of the [ABC] list items
[^ABC] can also use the range [A-z] for the list to represent the aabbcc...,[0-9] for the 012345 ...
{} Loop List

  Range of control variable names echo ${ab}c

  \ Turn Meaning

Basic usage of the shell

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.