Linuxshell programming 14 ---- learning shellscript

Source: Internet
Author: User
1shellscript is a program written using the shell function. This program uses a plain text file to write some shell syntaxes and commands in it with regular expressions, pipeline commands, data stream redirection, and other functions to achieve the purpose of processing 2 simply put,

1. shell script is a program written using the shell function. This program uses a plain text file to write some shell syntax and commands in it with regular expressions, pipeline commands, data stream redirection, and other functions to achieve the purpose of processing

2. Simply put, shell scripts are like batch processing files in the early DOS era (. bat), the simplest function is to write a lot of commands together, so that users can easily process complex operations at once.

3. shell script is a good tool for system management, but it is not enough to process a large amount of data operations because it is slow, the cpu resources used are too many, leading to poor allocation of host resources.

4 shell script considerations

1. analyze and execute commands from top to bottom and from left to right

2. execute commands as mentioned in chapter 5. multiple blank spaces between commands and parameters will be ignored.

3 blank lines are also ignored, and the resulting keys are also considered as space keys.

4. if a row contains too many contents, you can use \ [Enter] to expand to the next row.

5 # annotations

5. we can use source xx. sh to execute the script, but this script is executed in the parent process, so the variable degree in the script can take effect.

6. use the judgment symbol []

1. each component in the brackets [] must be separated by a space key.

2. it is best to enclose the variables in brackets in double quotation marks.

3. it is recommended that all variables in brackets be enclosed in single or double quotation marks.

7. default shell srcipt variables

1. the script file name is $0, and the first parameter is $1 ......

2 $ # indicates the number of parameters

$ @ Represents $1 $2 $3 ...... meaning that each variable is independent. All parameter strings

$ * Is similar to $ @.

8 shift in the shell script moves the variable, and the variable can be followed by a number to remove the first few parameters.

9 trace and debug shell scripts

Sh [-nvx] script. sh

-N: do not execute the script. only query the syntax.

-V first outputs the script content to the screen before executing the script

-X can output the entire script execution process to the screen.

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.