Shell Learning Summary (I.)

Source: Internet
Author: User


#! /bin/bash

#

The head can not be less, called the magic number, tell the computer is a shell script, with bash to execute it, otherwise unrecognized.

Shell script file to end with. SH, not necessary, just good identification, specification.

1.if condition judgment

if condition; then

The action performed

elif conditions; then

The action performed

Else

The action performed

Fi

If then the line, you can not write ";", but if you do not wrap, you have to ";" Seal No.

2. Conditional test Expressions

[expression] or test expression, note: [Space expression space], space can not be less

A. Integer comparison

-GT is greater than, greater than true

-eq equals

-ne Not equal to

-lt less than

-ge greater than or equal to

-le less than or equal to

B. Document judgement

-E exists, directories can also

-D Directory

-F Normal File

-r,-w,-x, do you have the appropriate permissions

C. Character testing

= = is equal, an equal sign can also [space "" Space = = Space "" Space ") equals must have spaces at both ends

! = Unequal

>,< greater than, less commonly used

-N string is empty

-S non-null

3.for Cycle

for variable in list; Do

Cyclic action

Done

A. Generation of lists

{value, Value .... }

Implemented with the SEQ command

Seq Start number Step length end number of which the step length and the starting number can be saved, default starting from 1, use the note command with the anti-quote or $ () call


This article from "ayf755" blog, declined reprint!

Shell Learning Summary (I.)

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.