Small summary of Shell learning----Chapter Summary

Source: Internet
Author: User
Tags arithmetic

Summary of this chapter

Variables are a must in a very small program . The shell variable retains the string value , and a large number of operators can be ${var ...} used in , let you control the result of the variable .

Shellprovides a number of special variables(For example#?with the$!),used to access special information,For example,Command Exit Status. ShellThere are also many pre-defined special variables,For examplePS1----used to set the main prompt.positional parameters and$*and the[email protected]Special variables of this type,is used in the script(or function)is quoted as,allows users to access the parameters being used. Env,exportas wellReadOnlyis used to control the environment.

$((...)) The arithmetic expansion provides the complete arithmetic operation Ability , and use with C the same operators and precedence .

The exit status of the program is a small integer that can be used by the user after the program is completed ; shell scripts use exit order to do this thing , and Shell function uses the return Command . Shell scripts can be obtained in special variables $? The exit status of the last command executed within .

Exit status can be combined with if,while and until statements for Process Control , or with !,&& and | | operator with .

The test command and its aliases [...] can be tested for file attributes and strings and values , in if,while and in the until statement , He is also quite useful .

Forprovides a looping mechanism that iterates through the entire set of values,this whole set of values can be a string,file name or other, etc.. whilewith theuntilprovides a more traditional way of looping,Plus Breakand theContinueprovides additional loop control. caseStatement provides a multiple comparison function,similarCwith theC + +inside theSwitchStatement.

Getopts,shift and $# provide tools to handle the command line .

The last Shell function organizes the related commands together , and then treats it as a separate call to use . They're kind of like Shell Script , But he kept the order in memory. , It's more efficient . , and they can also affect the variables and states of the reference script .

Small summary of Shell learning----Chapter Summary

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.