Linux Control Structure

Source: Internet
Author: User
Linux control structure-general Linux technology-Linux programming and kernel information. The following is a detailed description. Ignore the referenced value in double quotes in Linux, except $ '\.

Ignore all referenced values in single quotes

For example, echo '$ Test'

$ Test

Reverse quotation marks: Use the content as a command

////////////////////////////////////

Condition test: 0 true, 1 false

Test condition or [condition]

1) file [-w 1.txt? O? R 2.txt]

2) string [$ EDITOR = "vi"] = ,! =,-Z,-n

3) value [$ number? Eq "12"]? Eq,-ne,-gt,-lt,-le,-ge

4) Loop = 'expr $ loop + 1' let x = $ x + 1

//////////////////////////////////////// /////////////////

1) If ["10 "? Lt "12"]; then

Echo "yes"

Fi

If [-t] test whether the interactive mode is used

Empty command: elif else

2) for loop in 1 2 3 4 5 (list such as 'LS ')

Do

Echo"

Done

3) while [$ counter lt "5"]

Do

Echo ""

Done

Other break and continue

Case,

//////////////////////////////////////// //

Number of parameters $ #, parameter $ @, exit Status $?

[Function] message ()

{...

}

Message "hello" "world"

Parameter: $1, $2 ,...... $9

It retains the current s h e l and memory information. In addition, if you execute or call another piece of code in a script file, a separate s h e l will be created, thus removing all existing variables defined in the original script.

Once the file is loaded into s h e l, you can call the function in the command line or script. You can use the s e t command to view all definitions.

. The output list contains all functions loaded into s h e l.

To change the function, run the u n s e t command to delete the function from s h e l, even though u n s e t deletes the function to facilitate this function.

Numbers are not available for s h e l or scripts, but they are not actually deleted. After the modification, re-load the file. Some s h e l will identify the changes and do not need to use the u n s e t command, but for security reasons, it is best to use the u n s e t command when changing the function.

Unset function_name

Locate function files

./Path
Source path

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.