The Shell of Linux

Source: Internet
Author: User

The shell is the interface that the user interacts with the system, which is one of the basic ways. The standard shell is bash.

Shell's Operation:

    1. Show all used commands: history.
    2. Execute a command that has been recently executed:!!。 The first one shows which instruction is executed, and then the effect is run.
    3. Execution of the history, nth instruction:!n.
    4. Executes the command beginning with the value string:!value.
    5. Print out the last instruction in history:!!:p.
    6. Get the last parameter of the previous instruction:!$. For example, perform cat first.c first, use!$ to get first.c, so you can use directly, like this LS!$.

Metacharacters: Predefined, special-meaning characters--shell will first find these metacharacters and specialize them before executing them.

Common metacharacters:

Wildcard: * matches any string, match any single character, [123] matches any one of the characters in the square brackets.

Command substitution: ' Commands ' =$: Converts a string into a command to execute.

Command combination execution: with; and (), such as date;who and (date;who).

Conditional execution, command sequence: with | | and &&, such as date| | who,| | The function is that the previous command failed to execute the next command, so this command only performs date;date&&who,&& to perform the last command, so that the next command executes, so both date and who are executed.

The value of the reference variable is $: for example, in the terminal, first a=10, and then a $ A to get the value of variable A, so echo $a, will print 10.

Shell input and output: standard device files. 0 is input, 1 is output. Each process will open these three files.

Input, output redirection:> redirect the standard output to the specified file,>> standard output is appended to the file;< standard input redirects to the file,<< the standard input is appended to the file. (Append does not cause redirection)

Examples of redirects:

Input redirection: First we can write some test text to a test file, and then in the Terminal Input command: Cat < test file, you can print the previous Test text in the terminal.

Output: e.g. who > test.c.

The addition is temporary.

Pipeline (special redirection): The output of the previous command, as input to the next command (that is, if the command has not been written, so you need to continue typing, then the other end of the pipeline as this input). For example, who | Wc-l count of users.

Shell Programming:

The Shell of Linux

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.