Bash script programming loop structure +linux package management (1)

Source: Internet
Author: User

August 16, the main study:

One, for loop

Second, while and until loops

Third, loop control statement continue and break

Iv. Package Basics

Five, RPM package management

One, for loop

1) format

For variable name in list;

Loop body

Done

2) Execution mechanism:

Assigns the element in the list to the "variable name" in turn; The loop body is executed once each assignment; until the elements in the list are exhausted, the loop ends

3) List Generation method:

1. Give the list directly

2. List of integers:

(a) {start: End

(b) $ (SEQ [start [step]] end)

3. command to return a list

$ (COMMAND) such as $ (LS/ETC/PASSWD)

4, using glob wildcard characters, such as: *.sh

5. Variable reference: [email protected],$*


Second, while and until loops

1) While loop

While CONDITION; Do

Loop body

Done

CONDITION: cyclic control conditions; Before entering the cycle, make a judgment; once each loop is judged again; the condition is "true", then a loop is executed until the condition test state is "false" to terminate the loop

Therefore: Condtion generally should have a cyclic control variable, and the value of this variable will be continuously corrected in the loop body

Entry condition: condition is true;

Exit Condition: Condition is false

2) until cycle

Until CONDITION; Do

Loop body

Done
Entry condition: CONDITION is False

Exit Condition: CONDITION is True


Third, loop control statement continue and break

1) Loop control statement continue

Continue [n]: end of the nth layer of the current cycle, and directly into the next round of judgment; the inner layer is the 1th floor.

2) loop control statement break

Break [n]: Early end of the nth layer cycle , the inner layer is the 1th layer


Iv. Software Package Management Basics

1) Software operating environment

Api


This article is from the "Laugh Monkey" blog, please be sure to keep this source http://xiaomonkey.blog.51cto.com/11869371/1839351

Bash script programming loop structure +linux package management (1)

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.