Recognize and learn Bash

Source: Internet
Author: User

The application is at the outermost, just like the shell of an egg, and is therefore called the Shell (Shell program). In fact the shell program is only a function of providing an interface to the operating system.

Application

Operating system (System call + Core)

Hardware

The Linux preset shell is bash

"tab": Command completion after the first word of a sequence of instructions

When the second word of a sequence of instructions is followed, the file is padded

Command alias setting function: (alias)

View all files (with hidden file) and all file attributes: Ls-al

Set alias command: Alias lm= ' Ls-al '

You can enter alias in the instruction column to know what the current naming alias is.

Type [-TPA] Name

: 1, without any options and parameters, type will show whether the name is external or bash built-in instructions

2. "-T": type will show the meaning of name with the words below:

File: Represented as an external directive

Alias: Indicates the name set by this directive for the command alias

Builtin: Indicates that the giant command was built for bash

"-P": The full file name is displayed when the name is followed by an external instruction

"-a": A path defined by the path variable that lists all instructions with name, including the alias

Reading and setting of variables: Echo unset

Using echo to read the variable, the variable must be read with a "$" format in front of it: Echo $variable or Echo ${var}

Setting and modifying the contents of a variable: format: var= content

such as: Echo $myname//Do not display any data, because this variable has not been set, is a null value

Myname=vbird//myname Set Value

echo $myname//Display Vbird

Note: In bash, when a variable name has not been set, the preset content is "empty"

Variable setting rules:

1. Variable and variable contents are connected by an equal sign "=", and cannot be directly connected to the whitespace on both sides of the equal sign

2. Variable names can only be English letters and numbers, but the starting character cannot be a number

3. Variable contents If there is a space, you can use the double quotation mark "" "or the single quotation mark" ' "to combine the contents of the variable, but

The special characters within the double quotation mark such as $ etc., can retain the original characteristics. [var= "Lang is $LANG"] [echo $var] get [Lang is en_US]

Special characters in single quotes are only ordinary characters (plain text), such as [var= ' Lang is $LANG '] [echo $var] get [Lang is $LANG]

4. Use the caret character "\" To turn special symbols ([enter],$,\, whitespace, etc.) into general characters

5. In a series of instructions, if you need to borrow information provided by other instructions, you can use the inverted single quotation mark "' instruction '" or "$ (instruction)". Note: ' Is the key to the left of the keyboard above 1, not the single quotation mark.

"Var=$ (Uname-r)" and "Echo $var" can get "2.6.18-128.el5"

6. If the variable is the content of the amplified variable, the contents can be accumulated using the "$ variable name" or the ${variable}. such as "Path=" PATH ":/home/bin"

7. If the variable needs to be executed in another subroutine, you need to export the variable into an environment variable: "Export PATH"

8. Cancel the variable unset, "unset variable name"

Example: unset myname

Recognize and learn Bash

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.